Start/Stop/Status init scripts
I am writing a custom legacy init script in Solaris 10 for testing purposes, which will be executing a dummy java program called SocketEcho. The problem is, I do not know how to stop the program correctly.
"pidof" is not available (from what I can tell). I will start the program with Code:
/opt/SocketEcho/SocketEcho Code:
java SochetEcho Now I have to stop the program with Code:
/etc/init.d/solarisSocketEcho stop Code:
ps -ef | grep SocketEcho Code:
java SochetEcho Code:
pkill "java SocketEcho" |
OK, you can't enclose the pkill argument with "quotes". to use pkill to stop the "SocketEcho" script you need to to "pkill -f SocketEcho". Obviously as root, if you did a pkill java this would stop the last java process that ran, which may not be what you want. but as you'll probably only have one SocketEcho running this will pattern match for it and stop the ID.
As the /etc/init.d/SocketEcho stop, this will only work if the /etc/init.d/SocketEcho script contains a 'stop' flag. You can put my above pkill -f... command in the 'stop' section of the init.d script so the process can be stopped upon reboot. Cheers, Stuart |
Ah, I thought I had tried that, but I guess I was doing something wrong before (or that I had misunderstood the -f option). I was skeptical of using quotes, but since my efforts to stop the program by passing SocketEcho had failed, that's all I had to run with.
That seems to have done the trick, thank you. |
All times are GMT -5. The time now is 08:31 PM. |