9

We have a scheduled task that sometimes hangs. It just stops responding. On Windows 2003, we had task scheduler configured to kill the task after 3 hours. It's a 32-bit process.

On Windows 2008 R2, we've set "Stop the task if it runs longer than" and "If the running task does not end when requested, force it to stop".

However, when the task hangs, it is never stopped, and stays in process explorer for days.

Any clue why Windows Scheduler would not kill a process?

(This post has a reproducible setup for this issue.)

5
  • What's the real question here? Aug 24, 2012 at 15:30
  • @HopelessN00b: Why does Win2008 not kill a scheduled task when it has run longer than the "Stop the task if it runs longer than" setting?
    – Andomar
    Aug 24, 2012 at 15:47
  • Because it tried, and failed for any number of reasons. There's no one reason, but it can be that it lacked permissions, the task failed to respond to the termination signal, the task was waiting on user input, locked by kernel resources, hung waiting on kernel resources, etc... Aug 24, 2012 at 16:13
  • @HopelessN00b: The task does not respond to anything-- it's stuck. Why does Win2008 not kill it (end process) like Win2003 did?
    – Andomar
    Aug 24, 2012 at 16:51
  • See my previous comment? Aug 24, 2012 at 17:12

2 Answers 2

10

The answer is that the 64-bit task scheduler will not actually kill a 32-bit task.

We solved this by running pskill as action 1 of the scheduled task. pskill has no problem dispatching a 32-bit processes.

4
  • I think I'm missing something here. How does having pskill as the first Action of a task enable the scheduler to kill the task if it times out?
    – Kit Roed
    Mar 19, 2014 at 14:00
  • @KitRoed: Say a task hangs. Then when the next scheduled run comes around, the first action will kill the hanging task.
    – Andomar
    Mar 19, 2014 at 15:01
  • 1
    Thanks for clearing that up. I may be able to use that approach, +1!
    – Kit Roed
    Mar 19, 2014 at 16:06
  • nice @Andomar. you asked and solved your own question
    – user421501
    Jun 21, 2017 at 22:30
2

Immediately below the "Stop the task if it runs longer than" is an option that says "If the running task does not end when requested, force it to stop". Is that 2nd option checked?

4
  • Yes, that option is checked (as mentioned in the question)
    – Andomar
    Aug 31, 2012 at 9:10
  • Man, I must have not been paying attention. if you launch it manually and kill it manually using the task scheduler GUI, do you get any kind of indication as to why it refuses to stop? Might be a gui popping up asking you "are you sure?". Another think you might be able to do is run taskkill and kill the task by name..
    – MikeAWood
    Aug 31, 2012 at 21:39
  • I've attached a debugger to the task, and it's hanging in a third-party DLL. It does not respond to anything. The question is why Task Scheduler doesn't kill it, using TerminateProcess, which kills a process no matter what
    – Andomar
    Sep 1, 2012 at 9:05
  • Is it launching the DLL as a seperate child thread? Its possible that its not ending the task because it is only killing the parent task and not the child. for instance, you would use "taskkill /T processname.exe" to kill the parent and child processes. Though I would expect the taskscheduler to kill child processes as well. Very curious.
    – MikeAWood
    Sep 4, 2012 at 20:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .