nohup (NOHUP)

nohup (short for “no hang up”) is a command in Unix-like operating systems, including Linux, that allows you to run another command or script in the background, even after you log out or close the terminal session. When you run a command with nohup, it ignores the SIGHUP (hangup) signal, which is normally sent to all processes when the terminal closes, ensuring that the process continues running.

The typical usage is:

nohup command &
  • command: The command or script you want to run.
  • &: Puts the command in the background.

By default, nohup redirects the command’s output to a file named nohup.out in the current directory, unless you specify a different output file. This is useful for long-running processes, like server scripts or data processing tasks, that you don’t want to be interrupted if your terminal session ends.

Example:

nohup python myscript.py &

This command runs myscript.py in the background, and the script will continue to execute even if you log out. Output is saved to nohup.out.

Leave a Reply

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