0
0
Linux CLIscripting~10 mins

nohup for persistent processes in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - nohup for persistent processes
Start command with nohup
Ignore hangup signal
Redirect output to nohup.out
Run command in background (&)
Process keeps running after logout
Check nohup.out for output
The flow shows how nohup runs a command ignoring hangup signals, redirects output, runs in background, and keeps running after logout.
Execution Sample
Linux CLI
nohup sleep 10 &
ps
cat nohup.out
Runs sleep 10 ignoring hangup, lists processes, then shows output file content.
Execution Table
StepActionCommand/SignalResultOutput
1Start command with nohupnohup sleep 10 &sleep runs ignoring hangupnohup: ignoring input and appending output to 'nohup.out'
2List processespsShows sleep process runningPID TTY TIME CMD ... sleep 10
3Check nohup output filecat nohup.outFile is empty (sleep has no output)
4Logout userexitsleep continues running
5After 10 secondspssleep process gone (finished)
💡 sleep 10 finishes after 10 seconds, process ends
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 4Final
sleep_processnot runningrunning (ignores hangup)runningrunning after logoutstopped after 10s
Key Moments - 3 Insights
Why does the process keep running after logout?
Because nohup ignores the hangup signal sent on logout, as shown in execution_table step 4.
Where does the output of the command go?
Output is redirected to nohup.out file by default, as shown in execution_table step 1.
What happens if the command produces no output?
nohup.out remains empty, as shown in execution_table step 3 with sleep command.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what message does nohup print when starting the command?
ACommand not found
BProcess started successfully
Cnohup: ignoring input and appending output to 'nohup.out'
DOutput redirected to /dev/null
💡 Hint
Check execution_table row 1, Output column.
At which step does the process continue running after the user logs out?
AStep 2
BStep 4
CStep 3
DStep 5
💡 Hint
Look at execution_table step 4, Result column.
If the command produced output, where would you find it?
AIn nohup.out file
BIn the terminal only
CIn /var/log/syslog
DNowhere, output is discarded
💡 Hint
See execution_table step 1, Output column about output redirection.
Concept Snapshot
nohup runs a command ignoring hangup signals
Redirects output to nohup.out by default
Use & to run command in background
Process keeps running after logout
Check nohup.out for command output
Full Transcript
The nohup command lets you run a process that keeps running even after you log out. It ignores the hangup signal sent when you exit the shell. When you run 'nohup sleep 10 &', it starts the sleep command in the background and redirects any output to a file called nohup.out. You can check running processes with 'ps' and see the output file with 'cat nohup.out'. Even if you log out, the sleep command keeps running until it finishes after 10 seconds.