Stop a task in Windows 2008 Task Scheduler if it runs longer than 15 minutes?

9,090

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.

Share:
9,090

Related videos on Youtube

Mouffette
Author by

Mouffette

Updated on September 18, 2022

Comments

  • Mouffette
    Mouffette over 1 year

    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
    Mouffette about 12 years
    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"
  • MikeAWood
    MikeAWood about 12 years
    According to "schtasks /create /?" the /DU option "Specifies the duration to run the task."
  • MikeAWood
    MikeAWood about 12 years
    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).
  • Mouffette
    Mouffette about 12 years
    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.
  • MikeAWood
    MikeAWood about 12 years
    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.
  • access_granted
    access_granted over 6 years
    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.