nohup Linux Command
Runs a command that keeps running even after the terminal session is closed.
What does nohup do?
Runs a command that keeps running even after the terminal session is closed.
Syntax
nohup command &Practical example
nohup ./long-script.sh &Questions about nohup
What does nohup do?
nohup (no hangup) makes a command immune to the SIGHUP signal, so it continues running after you log out or close the terminal.
How do I run a command in the background permanently?
Use `nohup command &` to run a command that persists after logout. Output goes to nohup.out by default.
How do I redirect nohup output?
Use `nohup command > logfile.log 2>&1 &` to redirect both stdout and stderr to a specific log file.
How do I check if a nohup process is running?
Use `ps aux | grep commandname` or `pgrep commandname` to find running nohup processes.
How do I stop a nohup process?
Find the PID with `pgrep commandname` and then use `kill PID` or `kill -9 PID` to force stop it.
What is the difference between nohup and disown?
`nohup` prevents SIGHUP from terminating the command. `disown` removes a job from the shell's job table. Use both for maximum persistence.
How do I see nohup output?
Output is saved to nohup.out in the current directory. Use `cat nohup.out` or `tail -f nohup.out` to view it.
How do I run nohup with a script?
Use `nohup ./script.sh &` to run a script. Make sure the script is executable with `chmod +x script.sh` first.
Related Process Commands
reniceChanges the priority (niceness) of an already running process.
pgrepSearches for processes by name and returns their PIDs.
niceRuns a command with a specified scheduling priority (niceness value).
psReports a snapshot of current running processes with their PIDs.
jobsLists active jobs (background and suspended processes) in the current shell.
topDisplays an interactive, real-time view of system processes and resource usage.