Saturday, February 03, 2007

Prevent Process Hangup on Log Out

Often I start processes in the background, but most of the time, I can not hang around until they are done due to other pressing sysad matters. For security reasons, I have to log off the computer when unattended and that event normally terminates the children of a process.

Here's an example of how I ensure my process(es) will continue regardless of log on status:

#nohup sort esofthub.dat > esofthub.sorted &

OR I can even mail the results to myself.

#nohup sort esofthub.dat > esofthub.sorted | nohup mailx -s "esofthub's sorted file" &

1 comment:

jrgrant said...

While the techniques you've described here are very useful, I've found the "screen" utility to be really handy for a long running task. Screen is immune to SIGHUP, but it also provides a mechanism to pick up a task where you left off if you need to log out. I've been able to go to dinner and finish up from home by using screen. It deserves a nook in the toolbox!