问题
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 :)
回答1:
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.
来源:https://stackoverflow.com/questions/3950585/starting-and-stopping-a-daemon-at-user-login-logout