inithave its our parent identified by PPID. When you start process using your current shell the shell itself becomes a parent for your newly started process. The trouble with this approach is that this may not be always desirable since when parent process is terminated its child dies with it. The happens very often when login into server using ssh, telnet etc. After log out parent shell is terminated and thus terminating all processes forked from it. Let's explore some way how to avoid this necessary but sometime undesired system behavior:
$ nohup myjobs.sh & nohup: ignoring input and appending output to ‘nohup.out’Entire output if any is appended to nohup.out file for later review
yescommand imitatively and at the same time detaching this process form a current working shell.
$ at now at> yes > /dev/null at>On the first line we started
job 2 at Thu Jun 26 11:12:00 2014
atcommand with time argument "now". Next, we time command we wish to run. lastly, by pressing CTRL+D key combination we send EOT ( End Of Text ) signal that we are done issuing commands and the job will start immediately. Listing current jobs using
jobscommand will produce no output which means we are free to disengage from our current shell without stopping any processes.
$ jobs + Running yes > /dev/null &if we log out now the process will be terminated and therefore we need to detach it form our current shell first:
$ disown %1 $ jobs $ ps aux | grep yes lubos 9257 96.9 0.0 107892 352 pts/5 R 11:23 1:30 yesAs you can see our process is no longer attached to our current shell.