Start tmux and execute a set of commands on boot

9,530

In my case, I have a user account just for the purpose of running one single script, so I provide a default tmux configuration in that user's home directory by creating a file ~/.tmux.conf

My ~/.tmux.conf file looks (roughly) like this:

new-session -d -s MYSESSIONNAME
set -g status off
new-window ~/my-startup-script.sh

my-startup-script.sh needs to have the +x permission set, obviously.

To start the ~/.tmux.conf tmux script, issue the command

tmux start-server
Share:
9,530

Related videos on Youtube

boolean.is.null
Author by

boolean.is.null

Updated on September 18, 2022

Comments

  • boolean.is.null
    boolean.is.null over 1 year

    I'm trying to find a way to have tmux start for a specific user on boot. The tmux session should run two Python scripts.

    I think I could start Python as mentioned here, but I'd rather have it in a tmux session.

    Is that possible and how could I accomplish that?

  • Valentyn
    Valentyn about 3 years
    How can I test if this works? I have created a ~/.tmux.conf file with just one line 'new-session -d -s tower', when I run 'tmux start-server', nothing happens. I don't see any new session created with 'tmux ls'.
  • am05mhz
    am05mhz almost 3 years
    when system rebooted, does the tmux auto start session run under root user or else?