5

In the Settings tab of a Task in Task Scheduler Windows 2008 and Win8 you can specify additional settings that affect the behavior of your task.

The setting for "Stop the task if it runs longer than:" only allows as low as 1 hour but is there any other way to specify in minutes effectively terminating my job if it runs long than 15 minutes?

Thanks.

Mouffette
  • 495
  • 7
  • 11

1 Answers1

1

enter image description hereYou can specify a duration in minutes from the command line using "schtasks /create". The /DU option allows for HH:mm So you should be able to set it for 15 minutes if needed.

MikeAWood
  • 2,566
  • 1
  • 12
  • 13
  • 2
    That /DU option seems to be related to the duration of the repetition interval and not the termination. The different tests I created at the command line never changed the "Stop Task If Runs X Hours and X Mins" setting (schtasks /query /fo LIST /v /tn test). I tested with a simple test but was unsuccessful: schtasks /create /tn test /du 00:01 /k /tr "ping.exe 127.0.0.1 -t" – Mouffette May 11 '12 at 06:23
  • According to "schtasks /create /?" the /DU option "Specifies the duration to run the task." – MikeAWood May 11 '12 at 20:36
  • I had a few options to your example to get it to accept it into the scheduler. But it does work and shows "2 Minutes as the duration". See the pic I added above. The command I used was [schtasks /create /tn test /du 00:02 /k /tr "ping 127.0.0.1 -t" /SC once /ST 13:35 /RI 1] – MikeAWood May 11 '12 at 20:43
  • 4
    Also, it appears that the GUI will let you manuall type in "1 Minute" into the duration drop down. I noticed that after i posted the above. So you probably can more easily just change it from the GUI, but keep in mind the duration time needs to be shorter than the repetition inverval (even if only running once). – MikeAWood May 11 '12 at 20:45
  • Thanks Mike but this is the wrong part of the UI, I'm trying to change the "Stop the task if it runs longer than". My task runs daily at 1 a.m. and i'm trying to kill the task if it runs for > 15 minutes. /DU refers to duration of the repetition of the task not how long the task process itself runs for. – Mouffette May 12 '12 at 02:37
  • 1
    Ah, that makes sense. The trick in the GUI for manually typing in the drop down text field of "1 Minute" does work as well in this case under the "Stop task if running longer than:" That is in the "Edit Trigger" window just below the "Repeat task every:" option. – MikeAWood May 14 '12 at 18:16
  • Keep in mind that some tasks will keep running if you specify "Stop the task if it runs longer than" in the Settings tab. This switch is really buggy and M$ folks have acknowledged that. Use the switch in the Trigger tab instead. – access_granted Dec 01 '17 at 02:24