apt-get install -t unstable daemon
It's not a lot of fun to program everything that really needs to be done for a proper daemon process. Some things you might not think of including moving to the root directory or somewhere else that you can be sure will never need to be deleted or unmounted, prohibiting core files,making sure any unexpected output goes either someplace reasonable or to /dev/null, disassociating from the terminal it started from, clearing umask and more. The "daemon" program takes care of these little details for you, freeing you to screw up your code in more interesting places.
With the "--respawn" option, daemon keeps your process running, but is smart enough not to keep respawning something that's dying too quickly (300 seconds by default but you can specify that too). Lots of other useful options for your convenience.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2009-11-07 Tony Lawrence