How to make a program running even after exiting shell

Jephe Wu - http://linuxtechres.blogspot.com

Objective: After you ssh into a server, you started a program or shell script. You need to keep it running even after you exit from shell.
Environment: CentOS 5.5


Methods:
1. use setsid 
setsid command
exit

2. use screen
screen
command
ctrl a then d [to deattach]
exit


ctrl d then r [to reattach]

3.  If you have plan to make it running after exit
nohup command & 
exit 

login again to use 'pstree | grep command' to make sure it's attached to init process instead of bash


4. If you forgot to nohup it and wants to exit shell now
command
ctrl -Z
bg [%1]
disown [-h]
exit 

login again to use 'pstree | grep command' to make sure it's attached to init process instead of bash


5. References
http://en.wikipedia.org/wiki/Nohup