0

I am having trouble executing at command via php. When I start this job, it runs the 1st time and creates a queue job 1 minute from it finishes the Run Logic. The queued job runs at specified time but it will not create a new job queue 1 minute after it completes the Run Logic so it dies.

The pseudo logic is
//task_queue.php
if(we_have_tasks){
Run Logic
shell_exec('/usr/local/bin/php -f task_queue.php | at now + 1 minutes');
}

What am I doing wrong? Any help is appreciated. I thought if I used the 'at' command I'll be able to schedule jobs without overlapping.

Thanks

Huseyin
  • 15
  • 2
  • see this. http://stackoverflow.com/questions/4421020/use-php-to-create-edit-and-delete-crontab-jobs – Milap Mar 14 '12 at 05:18

2 Answers2

0

I think you meant to write shell_exec('echo "/usr/local/bin/php -f task_queue.php" | at now + 1 minutes'); no? The version you've got re-runs immediately.

hobbs
  • 187,508
  • 16
  • 182
  • 271
0

You can try

exec('php /usr/local/bin/php -f task_queue.php | at now + 1 minutes');

Taco
  • 216
  • 1
  • 18