20

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.

Barry Jordan
  • 2,666
  • 2
  • 22
  • 24
  • Have you considered [Quartz.NET](http://quartznet.sourceforge.net/)? – Nano Taboada Oct 14 '11 at 15:40
  • @Nando - we work with Coldfusion, which is build on Java, so I had already checked out http://www.quartz-scheduler.org. I'm looking for a program that does not require custom code to be written, just a desktop or command line program that will allow me to make HTTP requests an intervals between 1 and 60 seconds. – Barry Jordan Oct 14 '11 at 15:46
  • Then I guess you might have better luck asking at [Super User](http://superuser.com/) as this site is mainly for programming questions. – Nano Taboada Oct 14 '11 at 15:50
  • @BarryJordan Could you consider moving your accepted answer to one or the other answers? it provides a better answer than your own for future users. – Tschallacka May 19 '17 at 09:22

4 Answers4

34

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.

Andre
  • 599
  • 1
  • 6
  • 20
  • 2
    I had to add two tasks as I could only add triggers for seconds 0 - 47 before encountering an error (schema error I presume). – baileyswalk Jan 08 '15 at 12:10
  • Check out [this related superuser post](http://superuser.com/a/668074/108939)- you just need to setup multiple triggers starting at different second offsets. – SliverNinja - MSFT Jan 08 '16 at 19:41
  • @SilverNinja Thanks for mentioning that related post. He is doing exactly what I described above. I edited my answer to clarify that the text file solution is just a more conventient way to set up the triggers compared to using the GUI, especially when setting up a task to run every second (rather than every 10 seconds like in that superuser answer) – Andre Jan 13 '16 at 15:29
  • 6
    There has got to be a special place in hell for whoever developed the Windows Task Scheduler – niken Aug 25 '16 at 19:13
13

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>
Philipp M
  • 1,877
  • 7
  • 27
  • 38
kralco626
  • 8,456
  • 38
  • 112
  • 169
  • 1
    This should be the accepted answer, much simpler than creating 59 triggers! – Geek Josh Aug 12 '19 at 15:08
  • 1
    The OP specified they wanted to run the task every x seconds rather than every minute which is not possible with the solution from this answer. So it may be simpler, but solves another problem than the 60 triggers. – Andre Jan 24 '22 at 14:56
3

I've googled this to death, so as far as I can see the answer is, there are none. There are plenty of commercial solutions, but no open source/free programs.

I ended up writing a very simple periodic HTTP GET scheduler in java using quartz scheduler. It may be useful to other so posting a link to the source on guthub https://github.com/bjordan/simple_java_periodic_HTTP_scheduler

Barry Jordan
  • 2,666
  • 2
  • 22
  • 24
1

Short explanation: Main program starts a service process that will stay active in memory and will periodically activate a job – do something.

Job scheduler

  1. Create a class that extends System.ServiceProcess.ServiceBase class
  2. Implement at least methods OnStart and OnStop
  3. Start and use Quartz.NET scheduler in OnStart to run tasks periodically

Here is my template C# solution for a Windows service and a Linux demon in .NET/Mono https://github.com/mchudinov/ServiceDemon And a short blogpost about it

    class Program
    {
        public static void Main(string[] args)
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { new ServiceDemon.Service() };
            ServiceBase.Run(ServicesToRun);
        }
    }

    public class Service : ServiceBase
    {
        static IScheduler Scheduler { get; set; }

        protected override void OnStart(string[] args)
        {
            StartScheduler();
            StartMyJob();
        }

        protected override void OnStop()
        {
            Scheduler.Shutdown();
        }

        void StartScheduler()
        {
            ISchedulerFactory schedFact = new StdSchedulerFactory();
            Scheduler = schedFact.GetScheduler();
            Scheduler.Start();
        }

        void StartMyJob()
        {
            var seconds = Int16.Parse(ConfigurationManager.AppSettings["MyJobSeconds"]);
            IJobDetail job = JobBuilder.Create<Jobs.MyJob>()
                .WithIdentity("MyJob", "group1")
                .UsingJobData("Param1", "Hello MyJob!")
                .Build();

            ITrigger trigger = TriggerBuilder.Create()
                .WithIdentity("MyJobTrigger", "group1")
                .StartNow()
                .WithSimpleSchedule(x => x.WithIntervalInSeconds(seconds).RepeatForever())
                .Build();

            Scheduler.ScheduleJob(job, trigger);
        }
    }

    public class MyJob : IJob
    {
        public void Execute(IJobExecutionContext context)
        {
            JobDataMap dataMap = context.JobDetail.JobDataMap;
            log.Info(dataMap["Param1"]);
        }
    }

Michael Chudinov
  • 2,620
  • 28
  • 43
  • Note that [link-only answers](http://meta.stackoverflow.com/tags/link-only-answers/info) are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Jan 18 '16 at 23:12