Skip to content

Instantly share code, notes, and snippets.

@karthicraghupathi
Created November 12, 2021 05:54
Show Gist options
  • Save karthicraghupathi/80847f0bdfb0adea682a8ae33b2e43e1 to your computer and use it in GitHub Desktop.
Save karthicraghupathi/80847f0bdfb0adea682a8ae33b2e43e1 to your computer and use it in GitHub Desktop.
SSH - Keep Tasks Running Through Disconnects
# For a command that is currently running.
# First suspend current command
CTRL + Z
# Get a list of current jobs
jobs -l
# Then resume execution of the command in the background
bg
# Finally disown the command so it continues to run on disconnecting terminal
disown -h %1
# When issuing new commands.
# The following will:
# - start executing the command and put it in background
# - redirect stdout and stderr to output.log
# - will also continue running the command on disconnecting terminal
nohup command > output.log 2&>1 &
# Get a list of current jobs
jobs -l
@karthicraghupathi
Copy link
Author

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