Reputation: 190
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?
Upvotes: 2
Views: 262
Reputation: 104
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.
Upvotes: 3