Gustav Schaffter wrote: > Hi, > > In my rc.local I start two instances of setiathome. > > When I do a shutdown, I'd like those two processes to be automatically > killed *before* the shutdown sequence starts. (I'd also like to execute > a quick non related 'cleanup' sequence.) > > Is there any rc file where I could store some kill `pidof setiathome` > commands? A file where I could store any commands that should be > executed first, in a shutdown situation? Some kind of logically > 'inverted rc.local'? > rc.local gives me nightmares. I used to administer these old SunOS 4.1.4 boxes (until entirely too recently), and there was no System V startup for that lame-o operating system. Everything had to be done in the /etc/rc.ip /etc/rc and /etc/rc.local The fun thing about these scripts is that if you screwed up line 2, then the program would exit at line 3. And any extra programs that were supposed to get started around line 10 wouldn't. So after a reboot, the webserver would mysteriously not start up, even though it was in the /etc/rc.local. And the most fun thing about that version of bourne shell is that there is no way to test the program without execution. So the only way to really test the script's sanity is to reboot. And your services may or may not start. rc.local is evil. Avoid it. Learn how to use System V startup scripts. It's painful, but worth it. in the /etc/rc.d/ directory, you will find bunches of bourne (again) shell programs. Each one of these is a neat tidy package to start and stop a service. The syntax is /etc/rc.d/init.d/progname start or /etc/rc.d/init.d/progname stop I don't have setiathome, but I wrote a feeble little start/stop script for you. No guarantees it'll work, though. After you get this, read 'man init'
#!/bin/sh # # Startup script for setiathome # # processname: setiathome # Source function library. . /etc/rc.d/init.d/functions # See how we were called. case "$1" in start) echo -n "Starting setiathome: " cd /home/pietb/setiathome ./setiathome & echo ;; stop) echo -n "Shutting down setiathome: " killproc setiathome echo ;; status) ps -ef |grep setiathome |grep -v 'grep' ;; restart) $0 stop $0 start ;; reload) echo -n "Reloading setiathome: " killproc setiathome -HUP echo ;; *) echo "Usage: $0 {start|stop|restart|reload|status}" exit 1 esac exit 0