I have a script that should be executed every n minutes. n minutes dynamically, so I could not set the cron job to call the script (at a specific time).
so what I did, I saved the time after every n minutes in the array, so when the script is executed, it first checks to see if the current time is in the array. if it is found in the array, it continues to execute, otherwise it will exit.
to execute the script, I have to use the cron job every minute to check the time in the array. Unfortunately, my web host only allows 5 minutes at least. so every time a script is called, I check if the values โโbetween $current_timeand $current_time + (4*60) // 4 minutesin the array are found. if so, and if necessary, I use a time_sleep_untilscript to delay until the time reaches the value found in the array.
so if my script runs at 10:05 and the value found in the array is 10:06, I let the script sleep until 10:06 before it continues to execute. however, if the sleep time is more than a minute or so, I get Mysql server gone away.
how can i prevent this? or is there a better way to do this?
thank!
source
share