I have a daemon written in PHP. I use the following command to call the daemon
php dojobs.php
when I call that command, the daemon runs infinitely because the file dojobs.php has the following code
while(true)
{
code here
}
I have the following questions:
I have the following code inside the daemon:
exec('nohup sendMail.php > /dev/null 2>&1 & echo $!';, $op);
(how do I make sure the nohup command above works correctly and that the sendMail.php file actually does its job? The sendMail.php is not a daemon. It sends an email and then quits.)
Thank you so much.
Not familiar with Monit, so can't help you with that. But instead of calling exec()
you can use the Process Control (pcntl_*()) extension to fork separate processes and wait for them to return a status code to the parent process, in order for it to know if the job has been successfuly completed or not.