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.