Skip to content

Instantly share code, notes, and snippets.

@lionell
Created July 28, 2017 02:19
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lionell/34c6d2bc58df11462fb73d034b2d21d1 to your computer and use it in GitHub Desktop.
Tmux systemd service
// Put this file in /etc/systemd/system/tmux.service
[Unit]
Description=Tmux server
[Service]
Type=forking
User=lionell
ExecStart=/usr/bin/tmux new -s 0 -d
ExecStop=/usr/bin/tmux kill-server
[Install]
WantedBy=multi-user.target
@ramezanifar
Copy link

Thank you for the sample.
I was struggling with my systemd service that starts a bash script in which a tmux session is created.
I realized defining the 'Type=forking' and 'User=***' are crucial otherwise
$tmux ls
results in an error:
no server running on /tmp/tmux-1000/default

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