0

From further investigation I have found there is an exact issue on how long certain instances of the task run for. most successfully run in a few seconds, yet a few consecutive tasks are running up to an hour (then stopped by the manager). At this point any information about Windows scheduled task life cycle would be appreciated


I have a php file which needs to be called every 10 minutes. The php file deals with new database entries that are updated on the call.

The file is executed via a scheduled task call to php.exe with -f argument (with said file after)

The task is performed as expected, and runs without fail. However, I have noticed two problems since its initial run.

1st, I had a file_put_contents on a log file which added a 'Schedule Task()' plus the current time, line every time the task ran.
For the first few days this ran fine, but it wasn't until one evening when command failed to execute as the log file had filled up (a .txt at just under 1GB). I checked, and the logfile read as:

Scheduled Task() 2014-10-10 18:00:00.000
Scheduled Task() 2014-10-10 18:00:00.000
Scheduled Task() 2014-10-10 18:00:00.000
(repeated for 1000s of lines, but still with milliseconds time incrementing every 500 lines or so)

Where I'd expect it to display as:

Scheduled Task () 2014-10-10 18:00:00.000
Scheduled Task () 2014-10-10 18:10:00.000
Scheduled Task () 2014-10-10 18:20:00.000

This suggests that the process got stuck on that line, as the milliseconds for 500 lines were equal.

To resolve this, I moved the file_put_contents line after an IF statement to ensure the line would only be written to the log file when new records were in the database.

The problem never happened again.

2nd, However, 3 weeks from the first scheduled task (today) I notice that the scheduled task's history is filled with errors, at a 10 minute incremental rate. The error code given is that of 'Duplicate instances running'. (Which is correct as I have set the option to not run instances if one is already in progress)

This, suggests that the Scheduled Task manager is executing the action multiple times (multiple processes).

At this stage, I'm not sure wether it is a fault by the scheduled task, or if it is a code issue where I am not correctly ending the file. Has anyone had a similar issue?

Update
From looking into the scheduled task manager logs, I can see that there is an issue with the task running longer than 1 hour

The call is running every 10 minutes however a few tasks run over & are stopped according to the 'stop task if run longer than hour' option

5
  • Moved from here: stackoverflow.com/questions/26303265/…
    – Simon.
    Oct 27, 2014 at 13:30
  • Primarily out of curiosity, did the wording actually change from "Schedule" to "Scheduled" or is that a typo?
    – user47584
    Oct 27, 2014 at 19:50
  • I'm not sure where you are referring too exactly, do you mean on the 'Schedule task()'? If so, that is just what is written out as text to the log. It reflects the function being called at that moment
    – Simon.
    Oct 27, 2014 at 20:05
  • Your two log files use different words: one is "schedule" and the other is "scheduled" with a "d". Probably just a typo, but, if it's not, something funny is going on.
    – user47584
    Oct 27, 2014 at 20:17
  • Ah, yup. With you now, that's a typo. My bad
    – Simon.
    Oct 27, 2014 at 20:18

0

You must log in to answer this question.

Browse other questions tagged .