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?