Wednesday, November 9, 2016

Running background jobs in Unix

When you execute a Unix job in the background ( using '&', 'bg' command), and logout from the session, your process will get killed.

You can avoid this by executing the job with 'nohup' (stands for no hang up).

Usage:
nohup {command-with-options} &

'nohup' is very helpful when you have to execute a shell-script or command that take a long time to finish. In that case, you don’t want to be connected to the shell and waiting for the command to complete. Instead, execute it with nohup, exit the shell and continue with your other work.

Explanation about nohup.out file:
By default, the standard output will be redirected to nohup.out file in the current directory. And the standard error will be redirected to stdout, thus it will also go to nohup.out. So, your nohup.out will contain both standard output and error messages from the script that you’ve executed using nohup command.

No comments:

Post a Comment