Friday, March 7, 2008

setsid: Keep Linux program running while you logs out


From man pages:

NAME
setsid - run a program in a new session

SYNOPSIS
setsid program [ arg ... ]

DESCRIPTION
setsid runs a program in a new session.


setsid runs a program in a new session, so even if you are log out of the session, your program will keep on running.

This is similar to "nohup" command - which allows you to ignore HUP (hangup) signal and keep running the command after user logged out.


"screen" is another good utility to achieve this.


e.g.

$ setsid ./memmonitor.sh '172.22.22.124'

so "memmonitor.sh" (an example script with “172.22.22.124” as first arg) will keep running till its done with its work, even if you are logged out of your session.

I will post a new post for "nohup" and "screen" soon.

No comments:

© Jadu Saikia www.UNIXCL.com