在用户登录注销时启动和停止守护进程
我有一个用 ruby 编写的守护进程脚本,它响应诸如守护进程启动和守护进程停止之类的命令。它可以使用 shebang #!/usr/bin/env ruby
执行,并且可以从终端调用。我需要在登录时启动守护进程并在注销时停止它。
背景信息:KDE、zsh。
我已经尝试使用 daemon start
和 daemon stop
制作两个单独的 shell 脚本,并将它们放在 ~/.kde4/Autostart
| 中。 ~/.kde4/shutdown
。脚本 start.sh
和 stop.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试将程序作为 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.