Skip to content

Instantly share code, notes, and snippets.

@cotyembry
Created August 21, 2017 00:26
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 cotyembry/0b66ae9e02d683da490ac036b804964c to your computer and use it in GitHub Desktop.
Save cotyembry/0b66ae9e02d683da490ac036b804964c to your computer and use it in GitHub Desktop.
Keep process running in background after disconnecting from ssh terminal session & &&

from: https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session The best way is often the simplest.

nohup long-running-command &

It was made specifically for this, it even logs stdout to nohup.log

man nohup

If you want to "background" some already running tasks, then your best bet is to ctrl+z then run

bg (this will background your most recent suspended task, allowing it to continue running)

then a quick disown should keep the process running after you log out.

screen and others can do it, but that's not what they're for. I recommend nohup for tasks you know your going to leave behind and bg for tasks your already running and don't want to re-start.

Keep in mind, both are bash specific. If you're not using bash, then the commands could be different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment