Linux nohup Command: Guide to Uninterrupted Background Processing
It is a common problem in Linux that when you start a process and close the terminal, the process stops.
nohup solves this problem by running processes independently of the session.
In this guide, you will learn how to manage your long-running tasks without interruption.
What Will You Learn in This Guide?
- Working logic of
nohupcommand - Automatically redirect output to files
- Run processes in the background without being connected to the terminal
- Monitor running processes and terminate them safely
Technical Summary
This guide covers the nohup command in Linux, which protects processes from the SIGHUP signal.
The goal is to ensure that long-term missions continue even if the terminal shuts down.
Topics covered:
- Basic nohup usage
- Output redirection
- Background process management
- Alternative vehicle comparison
What is the nohup Command?
nohup stands for “no hang up”.
Ignores the SIGHUP signal sent when the terminal shuts down.
In this way, processes continue to run in the background.
Basic nohup Syntax
nohup komut argumanlar
- This structure starts the command regardless of the session.
Applied nohup Examples
- Running a Simple Script
nohup ./hello.sh
- This command protects the script from the SIGHUP signal.
- Reading Default Output
cat nohup.out
- Command outputs are written to nohup.out file by default.
- Redirecting Output to Special File
nohup ./hello.sh > sonuc.txt
- This usage prevents nohup.out from occurring.
- Combining Error and Output
nohup ./hello.sh > tum_cikti.log 2>&1
- This command collects the error and output in a single file.
- Running Processes in the Background
nohup alone does not release the terminal. For this, & should be used.
nohup ping google.com &
- This command puts the process in the background.
- Finding and Stopping a Running Process
pgrep -a ping
- This command shows the process ID.
kill PID
- This command terminates the specified process.
| Vehicle | Intended Use | Interaction | Description |
|---|---|---|---|
| nohup | Protecting individual commands | None | nohup allows a command to continue executing even when logged out or exited the terminal. However, interaction in the terminal is limited. |
| screen | Leaving and returning from the session | Medium | screen allows you to create multiple virtual terminal sessions. It allows you to exit the terminal and return, but user interaction is possible. |
| tmux | Advanced session management | High | tmux offers screen splitting and multi-session management features. With high interactivity, you can manage multiple terminal sessions simultaneously. |
nohup is ideal for non-interactive work. tmux is suitable for long and interactive works.
Important Behaviors and Boundaries
-
If SSH fails, the process continues
-
After exit, the process continues to run
-
If the server reboots, the process stops
-
kill -9 stops nohup
-
Restart requires systemd services.
-
Logging and Disk Usage Warning nohup.out can grow rapidly during long-term operations. Redirect the output to special files to prevent the disk from becoming full.
-
You can use /dev/null if necessary:
nohup ./hello.sh > /dev/null 2>&1 &
Frequently Asked Questions (FAQ)
1. Can I close the terminal while using nohup? Yes. If you put it in the background with &, you can safely close it.
2. Will nohup work if the system reboots? No. Operations stop after reboot.
3. What happens if nohup.out gets too big? Disk space may run out. Manage or clear logs.
4. I'm getting a "Permission denied" error The script may not have permission to run.
chmod +x betik_adi.sh
Result
nohup is a simple and reliable solution for long-running operations on Linux. It works smoothly in production environments with correct logging.
You can safely use this method on your Linux servers on GenixNode infrastructure 🚀

