Skip to content

Instantly share code, notes, and snippets.

@michaeltelford
Last active February 10, 2025 18:47
Show Gist options
  • Select an option

  • Save michaeltelford/78c483e0b7c9cb719a0878661a644932 to your computer and use it in GitHub Desktop.

Select an option

Save michaeltelford/78c483e0b7c9cb719a0878661a644932 to your computer and use it in GitHub Desktop.
Linux tmux cheatsheet
# Linux tmux is used as a session manager to persist processes started from a SSH connection (which are killed
# by default on disconnect).
# Start a tmux session, then a daemon process and exit the session (which keeps the daemon running):
# ssh -i <foobar>.pem <ip-address>:22
tmux
# start a process with <cmd &> to start a daemon
Ctrl+B and then D # to exit the session
tmux ls # to view running sessions
tmux kill-session -t 0 # 0 here is the first tmux session in tmux ls but it might be different
tmux attach-session -t 0 # 0 here is the first tmux session in tmux ls but it might be different
# Killing a tmux session kills all processes started within it e.g. nginx server daemon
@michaeltelford

Copy link
Copy Markdown
Author

Another alternative is nohup e.g.

nohup ./server > server.log 2>&1 &

Starts the exe/script in it's own (daemon) process and writes output to log file. STDERR is redirected to STDOUT so both end up in the log file.

@michaeltelford

Copy link
Copy Markdown
Author

Also using nohup, you can combine it with overmind and a Procfile.

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