Oct 132010
 

tuxAs someone posted in a comment of one of my former article (nohup, bg e disown), i’ve forget a command: setsid, while talking about the possibility of detach a process from a terminal or a shell

man setsid
setsid - run a program in a new session

The main difference i see from nohup is that you “lost” your standard output, but for some programs this could be normal or acceptable.

Basic usage:
For example run a script called ~/src/compile.all on a remote machine:

ssh your.remote-box.com
setsid ~/src/compile.all
logoff (or < ctrl > D)

it’s also possible to pass arguments with setsid command:

setsid /usr/bin/totem '/path/to/my/file.avi'

Popular Posts:

Flattr this!

  2 Responses to “setsid – start programs in a new shell”

  1. hi:
    my demo:
    setsid mysql -uroot -pxxx
    it’s runing ok,but how can i return mysql shell ‘>’,
    please help

    • Hello,

      With setsid you “fire and forget” a process.
      To access mysql prompt you can connect to it via a mysqlclient.
      Or do you want to do something different ?

      Check also the commands & e fg.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*