Halden Notes

tmux sessions that survive a reboot

22 April 2026

Kernel updates reboot the box, and the tmux sessions go with it. Plugins can save and restore every pane, but all I need back is the same three sessions in the same directories.

#!/bin/sh
# ~/.local/bin/tmux-start
tmux has-session -t main 2>/dev/null && exit 0
tmux new-session -d -s main -c "$HOME/src"
tmux new-session -d -s logs -c /var/log
tmux new-session -d -s scratch -c /tmp

And a user unit that runs it:

# ~/.config/systemd/user/tmux.service
[Unit]
Description=tmux sessions

[Service]
Type=forking
ExecStart=%h/.local/bin/tmux-start
ExecStop=/usr/bin/tmux kill-server

[Install]
WantedBy=default.target

Then systemctl --user enable --now tmux, and loginctl enable-linger $USER so that the user manager starts at boot, without waiting for a login.

After a reboot tmux attach -t main lands where I left off — minus the running programs, which is fine: those I would restart anyway.