[eluser]paulipv[/eluser]
Example with date.
We have a task that run every minute.
And looks like crontab: * * * * *
Code:
while (true) {
$current = $daemon->current();
$scheduled = $daemon->scheluded($jobDate);
if (!$daemon->now() {
// is not programmed to run now
} else {
// run task ...
$nextScheludeDate = $daemon->next();
update jobs set next_shedule_date = $nextScheludeDate
}
}
Monitor from a linux server:
tail -f /var/log/daemon.log , there logs are rendered like:
[date] info: Starting daemon 'MyDaemonName' with PID: x
[date] info: Pid saved on /var/data/myDaemonName.pid
[date] info: Running job x with PID: pidID
[date] emerg: job x killed for high memory usage
[date] sys: Receive restart command