Multiple nohup.out Files

This entry is a reminder for myself more than anything, as it documents a very popular SO answer that is one of the first returns from Google when searching “nohup multiple out files”.

nohup.out is a file created automatically when you use type “nohup” in a bash terminal.  (“nohup” is short for “no hangup”, which means do not stop jobs when the connection to the server stops.)  This way, you can go back later to that file and see what was happening while you were away.

The problem is that any script launched with nohup will by default write to nohup.out.  If you are running multiple scripts, nohup.out will be very hard to read, as it will info from a bunch of different scripts all in one document.  It took me too many years to think about, but I realized I should be able to change this, and it turns out it is very easy to do so.

This StackOverflow answer shows how.  The key is to pipe the output to a new file.  Example:

nohup <program> thisScript &> <newNohup.out> &

Where <newNohup.out> is the filename to write out.  The ampersands simply tell bash to not wait until the command finishes executing before letting you enter new commands.  Otherwise, you would have to wait until the script runs or establish a new bash session to issue new commands.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.