当我运行 tmux Kill 会话时是否有 tmux 预命令

发布于 2025-01-15 13:29:06 字数 115 浏览 1 评论 0原文

假设我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

川水往事 2025-01-22 13:29:06

您可以使用 tmux hooks 来实现此目的。在您的 tmux.conf 中设置钩子,如下所示:

set-hook -g -n 'session-closed' 'run "<your command>"'

但我不确定您是否需要它。当 tmux Kill-session 运行时,tmux 内的所有进程都会收到 SIGHUP,因此它们应该自行正常退出。

You can use tmux hooks for this. Set the hook in your tmux.conf like this:

set-hook -g -n 'session-closed' 'run "<your command>"'

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.

萤火眠眠 2025-01-22 13:29:06

如果您的进程可以使用 Ctrl+c 终止,则可以使用名为 tmux- 的 tmux 插件safekill 可能可以解决问题。

If your process can be killed with Ctrl+c, a tmux plugin called tmux-safekill may do the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文