Forums

Scheduled Task Takes Forever, Once a Day

This is pretty strange, I know, but here is what I am seeing:

I have a scheduled task that runs every hour. Usually it takes just a few seconds to complete. The task itself is a very simple shell script that sets up the virtualenv and then runs a python script.

When I look at the log, almost always it takes less than 30 seconds to run. But it seems that the 7:00am run takes orders of magnitude longer: often 15000+ seconds. To troubleshoot this, I added debugs to every line of the script to print out a description and a timestamp. The very last line of the script prints the timestamp, and it's pretty normal: today's 7:00am run printed the last timestamp at 07:01:12. But the message that the task completed doesn't come until 11:12:07. And, the next run doesn't happen until 13:00.

Any ideas what is causing this gap from the last line of the script to when the scheduler thinks the task is done?

That's very odd. If you go to the "Schedule" tab in the period between the real end of the task running and the reported end, and hit the "Reload" button on the process list at the bottom, do you see any running processes?

If the pattern holds it will happen again in 12 hours, so I will try to look then, if I am still awake...

Hmmm, having thought about this a bit more -- we have a cleanup program that tries to identify out-of-control tasks and kill them. We run it manually most days, and today's run was about 11am. So that sounds like a likely culprit. So, no need to stay up -- I've asked Glenn, who'll be running it tomorrow, to take a look at your scheduled task processes just before and after he runs it. Perhaps that will shed some light on things.

Interesting. It does actually look like our clean-up script is doing something to your scheduled task. We'll have to do some more investigation, though.