3.4. The nohup command

If you are running a process and you don’t think it will be completed by the time you log out for the day, use the nohup command. Nohup will continue processing when you exit your account. Nohup means no hang up.

The general format of the command is:

nohup command & 

3.4.1. Submitting a job using nohup

Any output from your job will be redirected to a file called ‘ nohup.out ’, unless you specify otherwise with

nohup command >myout.file 2>&1 

which sends all output to the file myout.file.

Let’s do an example and test that it actually does continue working after you have logged out. We’ll kick off a log cleanup script called ps1.

							$ nohup ps1 & 
[1] 179 
$ nohup: appending output to `nohup.out`
						

Now exit the shell, log back ...

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.