当我运行 tmux Kill 会话时是否有 tmux 预命令
假设我有一个 tmux 会话,其中的进程像 docker 容器/wsgi 服务器等一样运行。
有没有办法定义一个“进程终止命令”,该命令将在 tmux 会话被终止之前运行? 会议结束后我不想要任何剩菜。
Suppose i have a tmux session with a process running like a docker container / wsgi server etc..
Is there a way to define a "process kill command" that will run before the tmux session is killed?
I don't want any leftovers when the session has stopped.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 tmux hooks 来实现此目的。在您的 tmux.conf 中设置钩子,如下所示:
但我不确定您是否需要它。当 tmux Kill-session 运行时,tmux 内的所有进程都会收到 SIGHUP,因此它们应该自行正常退出。
You can use tmux hooks for this. Set the hook in your
tmux.conf
like this:I am not sure you need it though. When
tmux kill-session
is run, all processes inside tmux will receive SIGHUP, so they should exit gracefully on their own.如果您的进程可以使用
Ctrl+c
终止,则可以使用名为 tmux- 的 tmux 插件safekill 可能可以解决问题。If your process can be killed with
Ctrl+c
, a tmux plugin called tmux-safekill may do the trick.