• I had installed Task Scheduler to run an API script in the background every couple minutes to update some data, but the data hasn’t been updating.

    When I looked, I saw that there was a huge queue of scripts running back several days, none of which had completed. When I cleared out the queue and ran it again all the numbers updated.

    I can’t tell what caused the huge backup or why none of the scripts ran. Looking in the PHP error log I see that there was a server outage at one point causing 500 errors, could that have caused the issue?

    Is there a way to prevent this sort of issue in the future – maybe some way to periodically delete out hung-up tasks and give the scheduler a fresh start?

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author miunosoft

    (@miunosoft)

    Hi,

    Maybe you should check the Handling Hung Routines option in the task editing page (Dashboard -> Task Scheduler -> Tasks -> Edit (of your choosing task) ).

    Hope this helps.

    Thread Starter dagfooyo

    (@dagfooyo)

    Thanks, that resolved the issue ??

    Plugin Author miunosoft

    (@miunosoft)

    Great!

    Would be appreciated if you could take a few minutes to write a review about this plugin. Thank you!

    Thread Starter dagfooyo

    (@dagfooyo)

    Actually it’s still not fixed ?? The tasks are getting hung up and then the tasks assigned to delete the old tasks are getting hung up. Also it looks like all of the tasks since one of these issues are timing out and getting deleted without completing.
    What else can I do to resolve this? The client is unhappy as this is the second week it hasn’t been working properly.

    What settings would you recommend to resolve this? Currently have it set as:

    Interval:
    every 2 minutes

    Max count of log entries: 0
    Max Task Execution Time: 30 seconds
    Execute the action even when the last routine is not completed.
    Handling Hung Routines: Terminate and remove the routine.

    I was thinking of increasing the interval to 10 minutes, and also the max execution time to 9 minutes in the hopes that will give the script enough time to run. Does this make sense? Anything else I can try to make this reliable?

    Plugin Author miunosoft

    (@miunosoft)

    Hmm,

    Indeed you should definitely try increasing the interval and the max execution time. Let’s see how it goes. If that fails, there will be nothing more you can try actually. In that case, I have to reproduce the problem on my end to examine what the real cause is so you need to tell me the steps to reproduce it.

    Thread Starter dagfooyo

    (@dagfooyo)

    OK I increased the execution time and it was fine for a while, but 5 days ago it hung up and just kept timing out tasks for the last 5 days ?? After I cleared out all the hung tasks and ran it again it worked correctly. What can I do at this point to make sure it works reliably? If anything?

    Thread Starter dagfooyo

    (@dagfooyo)

    It looks like once two instances of the automated tasks designed to clear out hung tasks themselves get hung, the whole thing grinds to a halt. Is there a way to just automatically clear out all tasks once an hour or something like that?

    Thread Starter dagfooyo

    (@dagfooyo)

    Here’s how I have it set now. Is this optimized for reliability, or would other settings work better?

    Server heartbeat: 24 seconds

    Max number of background routines: 12

    Max count of log entries – 0

    Max task execution time – 300

    Thread Starter dagfooyo

    (@dagfooyo)

    Another thing that would be useful is some way to generate an email if the tasks get hung for more than an hour or so. That way at least I would know it was happening.

    Plugin Author miunosoft

    (@miunosoft)

    Hi,

    I’ve posted a small plugin that periodically checks hung routines and deletes them. So you should try it. There is a download link in the page.

    And modify the following values to suit your needs.

    
        public $iElapsedTime    = 1800; // seconds - 30 minutes
        public $iCheckInterval  = 43200; // seconds - 12 hours
    

    $iElapsedTime should holds the elapsed time duration from the routine is started. iCheckInterval determines how often the check is performed.

    Hope this helps.

    • This reply was modified 7 years, 8 months ago by miunosoft.
    Thread Starter dagfooyo

    (@dagfooyo)

    Awesome! Thanks so much! I’ve installed the new plugin. I’ll let you know how it goes.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Task scheduler hung up and stopped completing tasks for several days’ is closed to new replies.