2

I work with add-on heroku scheduler Advanced Scheduler. I created a php script which works in CLI mode and is launched like php /app/crons/pushnotifications.php. In my Heroku plan I can run the script every 10 minutes, and in order to run it every minute I try to implement script restart every minute

$start = time();
while ((time() - $start) <= 9*60)
{
    $start_loop = time();
    something to do...
    sleep(max(0, 60-(time() - $start_loop)));
}

It looks like it does work fine but sometimes (once in two days this script crushed and I receive a letter on email "You are receiving this email because one of your scheduled tasks is failing to run properly").

How can I fix this issue?

Denis Cornehl
  • 4,104
  • 1
  • 20
  • 24
aid78
  • 190
  • 7

1 Answers1

3

I guess you can add something like this to the end of your command:

php path/file.php || echo "fail"

This will block the webhook on the fail. Yes, it's just a hack, but if everything works fine and you get such error messages, it will be useful for you.