Saturday, August 14, 2010

NOHUP : Run command continiously even if session closed

nohup command is used to run any command continiously even if you close your session from the server.


If nohup added in front of any command will continue running that command or process, even if you exit your terminal or close your session in that server


Syntax:


nohup command-to-run &


Where,


  • command-to-run : is name of command or script which you want to run. You can pass argument to that command or script.
  • & : nohup does not automatically runs the command in the background. you must do that explicitly, by ending the command line with an & symbol.



example:


# nohup /root/backup-script.sh error.log  2>&1  &