Forum Moderators: bakedjake
Thanks
cssmtp51> ps -ef ¦ grep spamd
admin 15065 1 0 16:44:09? 0:02 /usr/local/bin/perl /usr/local/bin/spamd -d -D -L -m 20 -u admin
root 15595 4129 0 17:17:19 pts/2 0:00 grep spamd
cssmtp51> kill 15065
cssmtp51> ps -ef ¦ grep spamd
root 15597 4129 0 17:17:31 pts/2 0:00 grep spamd
cssmtp51> /usr/local/bin/perl /usr/local/bin/spamd -d -D -L -m 20 -u admin
debug: Score set 0 chosen.
debug: running in taint mode? no
unix passed to setlogsock, but path not available at /usr/local/bin/spamd line 194
cssmtp51> ps -ef ¦ grep spamd
admin 15599 1 5 17:17:39? 0:02 /usr/local/bin/perl /usr/local/bin/spamd -d -D -L -m 20 -u admin
root 15601 4129 0 17:17:41 pts/2 0:00 grep spamd
If you aren't lucky enough to have that work, try writing a script to fork() and then exec() the program you want to kill and restart. The return value from fork() is either 0, -1, or the PID of a new child process. 0 means you're in the child process, and it's time to exec() your new program. -1 means something bad happened. Anything else means that's the pid of the child process you spawned, and you can record that someplace. (/var/run/spamd.pid would be typical) Then next time you script is called, it can read /var/run/spamd.pid, and kill the process with that number.
Of course, I've only ever actually *done* that in C, but I'm pretty sure Perl has wrappers around fork(), as do several other languages.