Keep running

2 snippets across 2 stacks - Bash & Linux, Docker

SHBash & Linux

Run Process After Logout

SH · Process Management
Syntax
nohup command [args] &
Example
nohup python3 etl_pipeline.py > etl.log 2>&1 &

Note nohup prevents the process from receiving SIGHUP when your shell exits. Output goes to nohup.out by default unless redirected. For more robust session persistence, consider tmux or screen.

DKDocker

Restart Policy (--restart)

DK · Run Options
Syntax
docker run --restart <policy> <image>
Example
docker run -d --restart unless-stopped --name web-api myapp:1.0
docker run -d --restart on-failure:5 --name worker myapp:1.0

Note Policies: no (default), on-failure[:max-retries], always, unless-stopped. 'unless-stopped' will auto-start on daemon boot unless you explicitly stopped the container. 'always' restarts even after manual stops on daemon restart.

Frequently asked questions

How does Bash & Linux handle keep running?
This task is covered in 2 stacks on this page: Bash & Linux, Docker. The "Run Process After Logout" snippet in Bash & Linux uses `nohup command [args] &`.
Which command does the Bash & Linux example use?
The "Run Process After Logout" snippet uses `nohup command [args] &`, from the Process Management section of the Bash & Linux cheat sheet.
Which stacks cover "keep running" on this page?
Bash & Linux, Docker. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Run Process After Logout": nohup prevents the process from receiving SIGHUP when your shell exits. Output goes to nohup.out by default unless redirected. For more robust session persistence, consider tmux or screen.