How to keep a script running even after logging out of the system

There are times when we need to do some job or run some script which takes a lot of time. During this the connection can get aborted which results in the job getting killed. There is simple solution for this, Use NOHUP.

The command syntax is easy:-
nohup <command>  &

here  <command> is the command or script you're running. An & is need to put the command in the background as nohup doesn't do this itself.

For example, when you log-in to the remote server using ssh.

# ssh [email protected]

now you want to run a backup script  which takes a long time, then you can run,

# nohup &

you can now logout from the terminal & the script will continue to run until its completed.


Post a Comment