I've got a number of php processes that I'm running in the background, with monit as the manager for them. My current config for monit looks like:
check process myprocess1 matching "process1.php" start program = "/usr/bin/php /path/to/process1.php > /var/log/process1.log" stop program = "/usr/bin/pkill /path/to/process1.php"
(Again, remember that there are several processes like this one.) This is working for starting processes, but not for stopping them -- the stop attempt fails with a monat "failed to stop" message. My current diagnosis of this situation is that it's failing because pkill isn't finding the process: doing the analogous
pgrep /path/to/process1.php fails to find anything.
ps ax shows, among other things:
5307 ? S 0:00 /usr/bin/php /path/to/process1.php
pgrep php succeeds in finding pids of all the php processes, but I only want to kill one of them.
So: Is there a way to get what I want here? I'm not wedded to using pkill, but it seems to be well thought-of...