Learned it from here http://stackoverflow.com/questions/6168781/how-to-include-nohup-inside-a-bash-script They use it to make current script daemoned but you can also make scripts that you run from within a script daemoned

Instead of doing

nohup prog &


nohup prog &> someoutput.txt &

which is 

nohup prog > someoutput.txt 2>&1 &

NOTE: > whatever 2>&1  is the same as &> whatever  in bash4 and ahead

Interesting alteranative

You can use redirects and disown instead of nohup

prog < /dev/null &> /dev/null & disown


prog < /dev/null > /dev/null 2>&1 & disown

or if you want output:

prog < /dev/null &> someoutput.txt & disown

You run process with /dev/null for input and output which unties it from output and input (you can give it some output if you want by modifying > or 2> or &>, just make sure to untie the input of stdin by doing </dev/null). Then we run it into background with &. Then we disown it (untie it from shell, so if shell turns off the process still runs).

The End

Leave a Reply

Your email address will not be published. Required fields are marked *