If you are connected to a remote Linux server via SSH and initiate a massive process—such as a database backup, a 100GB file transfer, or a complex machine learning script—you must keep your terminal window open the entire time. If your Wi-Fi briefly drops or you accidentally close the SSH window, the server will immediately terminate your running script, forcing you to start all over again. To prevent this, you should use the nohup command.
What Does ‘nohup’ Do?
The nohup (no hangup) command tells the Linux kernel to completely ignore the “hangup” signal that is sent when your terminal session disconnects. This allows your script to continue running safely in the background, even if you turn off your local computer.
How to Use nohup
Using the command is incredibly simple. You just place the word nohup directly in front of whatever command you were originally going to run, and append an ampersand (&) at the very end to push it to the background.
- Open your terminal and connect to your server.
- Type your command like this:
nohup ./massive_backup_script.sh & - Press Enter.
The terminal will print a message stating nohup: ignoring input and appending output to 'nohup.out'. Because the script is running in the background and you can no longer see its output on your screen, Linux automatically creates a text file named nohup.out in your current directory. You can check the progress of your script at any time by running tail -f nohup.out.