Monday, February 25, 2008

hup hup and away

I have used other ways to do this, and never really thought about this until somebody recently asked me how to run a command so that it continues to run even after you exit the terminal/logout.

Since I have been working with systems software development, the first thing that comes to my mind would be to make your executable a service and use the 'service [program] start/stop/restart' commands to control it.
The other option is to use a tool called 'screen' which I did try it for a few months, but never got comfortable with the scrolling up/down.

The simpler (and probably more obvious) way is to execute the program such that it is immune to hangups i.e. the 'nohup' command.

nohup ./keep_this_running

This will dump the output to a file called nohup.out.

To get more control over the output, try this:
nohup ./keep_this_running 1>output.log 2>error.log

No comments: