启动 tmux 并在启动时执行一组命令

boo*_*ull 7 startup boot tmux python autostart

我正在尝试找到一种方法让 tmux 在启动时为特定用户启动。tmux 会话应运行两个 Python 脚本。

我想我可以像这里提到的那样启动Python ,但我宁愿在 tmux 会话中启动它。

这可能吗?我怎样才能做到这一点?

小智 6

就我而言,我有一个用户帐户只是为了运行一个脚本,因此我通过创建文件 ~/.tmux.conf 在该用户的主目录中提供默认的 tmux 配置

我的 ~/.tmux.conf 文件看起来(大致)像这样:

new-session -d -s MYSESSIONNAME
set -g status off
new-window ~/my-startup-script.sh
Run Code Online (Sandbox Code Playgroud)

显然,my-startup-script.sh 需要设置 +x 权限。

要启动 ~/.tmux.conf tmux 脚本,请发出命令

tmux start-server
Run Code Online (Sandbox Code Playgroud)