小编afa*_*far的帖子

作为 systemd 服务运行两个 tmux 会话

我可以成功启动/停止创建 tmux 会话的服务。服务如下:
test1.service:

[Unit]
Description=First test service

[Service]
Type=forking
User=lancer
ExecStart=/usr/bin/tmux new-session -s test1 -d
ExecStop=/usr/bin/tmux kill-session -t test1

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

$ sudo systemctl start test1.service

$ sudo systemctl stop test1.service

都成功了。现在我想要另一个 tmux 会话,我可以从另一个服务控制它。所以我创建了这个 test2.service:

    [Unit]
    Description=Second test service
    
    [Service]
    Type=forking
    User=lancer
    ExecStart=/usr/bin/tmux new-session -s test2 -d
    ExecStop=/usr/bin/tmux kill-session -t test2
    
    [Install]
    WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

问题:两者中的任何一个都可以单独工作。我可以通过以下方式查看相应的 tmux 会话:
$ tmux ls
如果我启动其他服务,则不会发生任何情况。我只有之前的 tmux 会话。有人可以帮忙吗?

linux tmux systemd

7
推荐指数
2
解决办法
8387
查看次数

标签 统计

linux ×1

systemd ×1

tmux ×1