在用户登录注销时启动和停止守护进程

发布于 2024-09-28 03:16:26 字数 558 浏览 2 评论 0原文

我有一个用 ruby​​ 编写的守护进程脚本,它响应诸如守护进程启动和守护进程停止之类的命令。它可以使用 shebang #!/usr/bin/env ruby​​ 执行,并且可以从终端调用。我需要在登录时启动守护进程并在注销时停止它。

背景信息:KDE、zsh。

我已经尝试使用 daemon startdaemon stop 制作两个单独的 shell 脚本,并将它们放在 ~/.kde4/Autostart | 中。 ~/.kde4/shutdown。脚本 start.shstop.sh 在终端中运行,但在自动启动或关闭方面没有运气。

我无法将它们分别放入 .zshrc.zlogout,因为我在工作会话中启动了许多登录 shell。

所以我被困住了:)有什么想法吗?

更新: F1 =>帮助 :)

I have a daemon script written in ruby which responds to commands like daemon start and daemon stop. It's executable with shebang #!/usr/bin/env ruby and it works invoked from terminal. I need to start the daemon on login and stop it on logout.

Background info: KDE, zsh.

I already tried to make two separate shell scripts with daemon start and daemon stop and place them in ~/.kde4/Autostart | ~/.kde4/shutdown. The scripts start.sh and stop.sh are working in terminal, but no luck in autostart or shutdown.

I can't put them in .zshrc respectively .zlogout, because I start many login shells in a work session.

So I am stuck :) Any ideas?

Update: F1 => Help :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

禾厶谷欠 2024-10-05 03:16:26

您可以尝试将程序作为 autostart 应用程序运行,然后让它观察其父级(可能是会话管理器)何时停止运行。

You could try running the program as an autostart app, and then have it watch to see when its parent (probably the session manager) stops running.

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