Skip to content

Instantly share code, notes, and snippets.

@repodevs
Created September 8, 2019 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save repodevs/84300268e0ff23195cf2792f90011efe to your computer and use it in GitHub Desktop.
Save repodevs/84300268e0ff23195cf2792f90011efe to your computer and use it in GitHub Desktop.
Linux command to run script (program) in background without killed
# when we running script in background using `&` after we logout, the script will be killed,
# to prevent the script being killed we can use `nohup`
$ nohup bash -c "time python myapp.py" > myapp.log 2>&1 &
# this command will run our script in background (even we logout from terminal session)
# and we can still watching the log from `myapp.log`
# e.g `tail -f myapp.log`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment