Hey all,
I have several cron jobs running but some of them take a lot of time to complete, since it requires fetching data from an external website and then updates my site's database. My hosting provider has a 120 second time limit for PHP scripts, which is too low for my script, the reason why I run that script in blocks, I mean, I update as much as I can in 120 seconds and then, 3 minutes later, the next cron task picks up where last cron left off, and so on until it completes.
Additionally, I edited my script so that it would insert a new "activity feed" in a DB table when it was completed. The script measures time from the start to the very end and includes that in the mysql statement. (to clarify, it measures time for the current script, not cumulative with the previous one)
Now, checking the activity feed after the script ran, I've noticed that sometimes the script runs for more than 1900 seconds! That's over half an hour! I don't think i'll even take that much time to update all my database with the external site info, but since it's done record by record, one at a time (over 1200 rows) who knows. Anyway, I'd like my script to run for 120 seconds, get shut down by the time limit, then wait 3 minutes for the next script to pick up where the last one left off, but this is not happening. Instead, I get all of the cron tasks run for their full duration ignoring the time limit, and I haven't used set_time_limit(0);
in my code, which would be my first clue.
I re-checked my host's php.ini and yes, the time limit is set to 120.
Any ideas why this is happening? I don't want to get in trouble with my hosting provider, I'm sure that as soon as they notice this, they'll warn me or worse. Is there any way I can make sure that the script doesn't run for more than 120 seconds? I trying setting time limit myself to 120 but no luck.