You are not logged in.
i'm trying to follow https://wiki.archlinux.org/index.php/Tm … ialization
so i have :
~ ❯❯❯ cat /etc/systemd/system/tmux@dieter.service
[Unit]
Description=Start tmux in detached session
[Service]
Type=forking
User=dieter
ExecStart=/usr/bin/tmux new-session -s %u -d
ExecStop=/usr/bin/tmux kill-session -t %u
[Install]
WantedBy=multi-user.targetthis seems to start tmux, but i can't actually use it:
~ ❯❯❯ ps aux | grep tmux ⏎
dieter 538 0.0 0.0 21824 2612 ? Ss 11:52 0:00 /usr/bin/tmux new-session -s dieter -d
dieter 16761 0.0 0.0 10732 2312 pts/1 S+ 21:15 0:00 grep --color=auto tmux
~ ❯❯❯ tmux ls
error connecting to /tmp/dieter/tmux-1011/default (No such file or directory)
~ ❯❯❯ ls -alh /tmp/dieter/tmux-1011
total 0
drwx------ 2 dieter dieter 40 Nov 1 11:52 .
drwx------ 7 dieter dieter 140 Nov 1 11:52 ..interestingly, i can just invoke the same command manually and then it does seem to work:
~ ❯❯❯ /usr/bin/tmux new-session -s dieter -d
~ ❯❯❯ ps aux | grep tmux
dieter 538 0.0 0.0 21824 2612 ? Ss 11:52 0:00 /usr/bin/tmux new-session -s dieter -d
dieter 16839 0.0 0.0 21828 2604 ? Ss 21:17 0:00 /usr/bin/tmux new-session -s dieter -d
dieter 16854 0.0 0.0 10732 2368 pts/1 S+ 21:17 0:00 grep --color=auto tmux
~ ❯❯❯ ls -alh /tmp/dieter/tmux-1011
total 0
drwx------ 2 dieter dieter 60 Nov 1 21:17 .
drwx------ 7 dieter dieter 140 Nov 1 20:56 ..
srw-rw---- 1 dieter dieter 0 Nov 1 21:17 default
~ ❯❯❯ tmux -ls
tmux: unknown option -- s
usage: tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name]
[-S socket-path] [command [flags]]
~ ❯❯❯ tmux ls ⏎
dieter: 1 windows (created Sun Nov 1 21:17:25 2015) [191x56]so it looks like when system tries to run it during boot, it's unable to create the default file in /tmp/dieter/tmux-10111 (however it does succeed in creating the directory, weirdly enough?)
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
i tried removing the global unit and instead doing it on user level:
~ ❯❯❯ cat .config/systemd/user/tmux.service
[Unit]
Description=Start tmux in detached session
[Service]
Type=forking
ExecStart=/usr/bin/tmux new-session -s %u -d
ExecStop=/usr/bin/tmux kill-session -t %u
[Install]
WantedBy=default.target
~ ❯❯❯ ls -alh .config/systemd/user/default.target.wants
total 8.0K
drwxr-xr-x 2 dieter dieter 4.0K Nov 1 21:53 .
drwxr-xr-x 4 dieter dieter 4.0K Nov 1 21:53 ..
lrwxrwxrwx 1 dieter dieter 46 Nov 1 21:53 tmux.service -> /home/dieter/.config/systemd/user/tmux.service
~
~ ❯❯❯ ps aux | grep tmux ⏎
dieter 699 0.0 0.0 21824 2612 ? Ss 21:54 0:00 /usr/bin/tmux new-session -s dieter -d
dieter 2948 0.0 0.0 10732 2252 pts/3 S+ 21:57 0:00 grep --color=auto tmux
~ ❯❯❯ but same problem:
~ ❯❯❯ tmux ls ⏎
error connecting to /tmp/dieter/tmux-1011/default (No such file or directory)
~ ❯❯❯ ls -alh /tmp/dieter/tmux-1011
total 0
drwx------ 2 dieter dieter 40 Nov 1 21:54 .
drwx------ 6 dieter dieter 120 Nov 1 21:54 ..< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
Where are you setting the temp dir to “/tmp/dieter”?
Note systemd units do not create a login shell, so consequently they do not read any startup scripts (e.g. /etc/profile, .bashrc). See systemd.exec man page for list of environment variables that are available.
You'll probably find there is a “/tmp/tmux-1011” directory, which was created by the tmux started by the systemd unit, as the default temp dir is of course “/tmp”.
1) You can use the -S option to tmux commands to specify the full path of the socket. E.g.
tmux -S /tmp/tmux-1011/default ls Or 2) set TMUX_TMPDIR to /tmp wherever you set TMPDIR (TMUX_TMPDIR overrides TMPDIR)
Or 3) try adding the following lines to the [Service] section:
Environment=TMPDIR=/tmp/%u
ExecStartPre=/usr/bin/mkdir -p -m 700 ${TMPDIR}Offline
hmm i'm using zprezto which creates a $TMPDIR variable in .zprofile (see https://github.com/sorin-ionescu/prezto … ofile#L70), $LOGNAME is set to `dieter` so that checks out.
a bunch of the modules rely on $TMPDIR being set, though i don't think they actually care what dir $TMPDIR is set to.
you're right btw, /tmp/tmux-1011 exists and has the default symlink in it.
i'm gonna try your 3rd solution, i want to standardize on using the same tmp dir everywhere.
thanks!
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
it works, but now the only problem is `systemctl status tmux@dieter.service` reports failure, even though it seems to work fine :?
~/.c/s/user ❯❯❯ cat tmux.service
[Unit]
Description=Start tmux in detached session
[Service]
Type=forking
Environment=TMPDIR=/tmp/%u
ExecStartPre=/usr/bin/mkdir -p -m 700 ${TMPDIR}
ExecStart=/usr/bin/tmux new-session -s %u -d
ExecStop=/usr/bin/tmux kill-session -t %u
[Install]
WantedBy=default.target
~/.c/s/user ❯❯❯ systemctl status tmux@dieter.service
● tmux@dieter.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
~/.c/s/user ❯❯❯ journalctl -b | grep tmux ⏎
Nov 03 12:27:02 dieter-m6800 systemd[672]: Starting Start tmux in detached session...
Nov 03 12:27:03 dieter-m6800 systemd[672]: Started Start tmux in detached session.
~/.c/s/user ❯❯❯ ps aux | grep tmux
dieter 684 0.0 0.0 21824 2640 ? Ss 12:27 0:00 /usr/bin/tmux new-session -s dieter -d
dieter 3249 0.0 0.0 10732 2372 pts/2 S+ 12:30 0:00 grep --color=auto tmux
~/.c/s/user ❯❯❯ ls -alh /tmp/dieter/tmux-1011/default
srw-rw---- 1 dieter dieter 0 Nov 3 12:27 /tmp/dieter/tmux-1011/default
~/.c/s/user ❯❯❯ tmux ls
dieter: 1 windows (created Tue Nov 3 12:27:03 2015) [80x23]
~/.c/s/user ❯❯❯ < Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
Shouldn't you be using:
systemctl --user status tmux@dieter(From the “WantedBy” I guess you're using a user service, not a system one)
Offline
good point. looks the same though
~ ❯❯❯ systemctl status tmux@dieter.service
● tmux@dieter.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
~ ❯❯❯ systemctl --user status tmux@dieter.service ⏎
● tmux@dieter.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
~ ❯❯❯ systemctl --user status tmux@dieter ⏎
● tmux@dieter.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
~ ❯❯❯ ⏎< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
Sorry, I just noticed you called it “tmux.service”, NOT “tmux@dieter.service”
So you just need to do
systemctl --user tmuxOffline