keep a command running after logout

Start a long job so it survives closing the terminal or the ssh session, and come back to it.

  • processes
  • shell

Steps

  1. nohup long-command > out.log 2>&1 &

    start it in the background, immune to the hang-up

  2. tmux new -s work

    or start it inside a tmux session; Ctrl+B then D leaves it running

  3. tmux attach -t work

    come back to it later, even from another ssh login

  4. screen -S work

    the same with screen; Ctrl+A then D leaves it

  5. screen -r work

    come back to the screen session

  6. disown -h %1

    already running? Ctrl+Z, then bg, then this, and it survives logout

Commands used

  • nohup
  • tmux
  • screen
  • disown

Each has a page in lore: lore nohup opens it.