Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows task scheduler to execute tasks in seconds

I'm looking for an open source/free task scheduler for Windows 7 (development machine) that will allow me to schedule tasks (HTTP requests to a web service) to run every x seconds.

I've tried a couple of Cron clones and windows own Task Scheduler but neither seem to allow tasks to run at intervals less than 60 seconds. Am I missing something? I don't want to have to go and write any custom scripts either if possible.

like image 410
Barry Jordan Avatar asked Oct 14 '11 15:10

Barry Jordan


2 Answers

It is possible to create multiple triggers for one scheduled task. If you create 59 identical triggers with an offset of 1 second to each other, and schedule the task itself to run every minute, you end up the scheduled task to run every second.

You could create those 59 triggers manually using the GUI. However, a much quicker way to create so many triggers is to create a task with one or two triggers, export it to a text file, duplicate the according lines, change the start offsets accordingly, and then re-import the file.

like image 153
Andre Avatar answered Sep 30 '22 07:09

Andre


I was actually able to achieve this.

Update: Seems I over complicated it.

In the trigger, where it says "Repeat task every:" you can actually TYPE into the drop-down "1 minute" (It wont let you type the time in seconds)

I did this on a Windows 7 machine.

Also, I clearly did not read the question well enough, as the asker seems to already have been able to get the time down to 1 minute. However, I'll leave this answer here, as it will explain for future readers exactly how to get the time down to one minute.

It does seem as though you cannot get it to run at an interval of less than one minute.


I set up a task with a trigger set to Daily to recur every 1 day. I check the "Repeat task every:" box. Setting it to 5 Minutes for a duration of 1 day

This makes the task go forever, every 5 minutes.

I then exported the task. It exports to a .xml file.

Under Task > Triggers > CalendarTrigger > Repeition there is the following tag: <Interval>PT5M</Interval> I changed it from PT5M to PT1M. I re-imported the task.

The task now runs every 1 minute.

I have not fully tested this, and I have not tried with less than one minute, but it might be possible by putting PT30S or something for 30 seconds. I'll try it out and report back. Update: You cannot do this, you get an error when importing the task. It's not possible to set this time to less than 1 minute.

The whole trigger looks like this for me:

  <Triggers>
    <CalendarTrigger>
      <Repetition>
        <Interval>PT1M</Interval>
        <Duration>P1D</Duration>
        <StopAtDurationEnd>false</StopAtDurationEnd>
      </Repetition>
      <StartBoundary>2013-11-07T17:04:51.6062297</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
like image 23
kralco626 Avatar answered Sep 30 '22 06:09

kralco626