8

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.)

Andomar
  • 943
  • 1
  • 10
  • 23
  • What's the real question here? – HopelessN00b Aug 24 '12 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 '12 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... – HopelessN00b Aug 24 '12 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 '12 at 16:51
  • See my previous comment? – HopelessN00b Aug 24 '12 at 17:12

2 Answers2

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.

Andomar
  • 943
  • 1
  • 10
  • 23
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?

MikeAWood
  • 2,566
  • 1
  • 13
  • 13
  • Yes, that option is checked (as mentioned in the question) – Andomar Aug 31 '12 at 09: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 '12 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 01 '12 at 09: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 04 '12 at 20:34