Disowning terminal programs so that they dont exit when terminal is closed

From Notes_Wiki

Home > CentOS > CentOS 6.x > Server administration tips and tricks > Disowning terminal programs so that they dont exit when terminal is closed

Normally if we run program in background such as

./program1 >/dev/null 2>&1 &

and then exit terminal the program can continue running after terminal is closed. However if we start program using

./program1

and then use 'Ctrl+Z' and 'bg <n>' to send it to background then it remains connected to terminal such that if terminal is closed a SIGHUP is sent to the program to terminate it. To avoid this SIGHUP signal from being sent one can use

disown <n>

where n is same as listed in jobs. Or simple use 'disown' to disown all associated jobs. After disowning exiting the terminal wont send SIGHUP signal to process, allowing it to run until its formal completion.


Home > CentOS > CentOS 6.x > Server administration tips and tricks > Disowning terminal programs so that they dont exit when terminal is closed