Skip to content

Instantly share code, notes, and snippets.

@ziritrion
Created September 7, 2021 18:27
Show Gist options
  • Save ziritrion/44347b60da365839bf70962c2ba2fedb to your computer and use it in GitHub Desktop.
Save ziritrion/44347b60da365839bf70962c2ba2fedb to your computer and use it in GitHub Desktop.
SSH quick reference for running processes in the background
  1. SSH with local X (any X window should be run locally rather than remotely)
    • ssh -X user@instance
  2. Leave a process running even when you leave the SSH session
    • Make your script executable with chmod +x main.py
    • 2 possible instructions:
      • If console output does not matter (console output is still available in nohup.out but only if execution is finished successfully):
        • nohup python main.py &
      • If output must be saved even if you interrupt the execution:
        • (bash) nohup python -u main.py > output.log &
        • (zsh) nohup python -u main.py > output.log &!
    • exit

References:

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