17

In my windows, I want to schedule a windows service to start once every 10 seconds. I tried using the windows task scheduler but it only gives me an option to repeat the service daily, weekly and monthly.

Is there a way I can schedule the windows service to start once every 10 seconds using windows task scheduler?

What could be done?

  • 1
    After the service is started you can just execute the operation you want every 10 seconds from inside the service. – user77188 Jun 6 '11 at 8:18
  • What are you trying to execute every 10 seconds please? – KCotreau Jun 6 '11 at 11:17
  • +1 Is that possible? – alex Nov 4 '12 at 0:13
  • 1
    What does it matter what you are trying to execute? How about a simple http get? Why does windows SUCK SO MUCH – hahahahahahahaha Aug 25 '16 at 19:10
4

To do that, you should write a windows service, as that is what they are for.

35

A Windows Task Scheduler trigger cannot repeat more often than every 1 minute, but you can set up multiple triggers. To run a task every 10 seconds, add six Triggers. Each one should run the task Daily, and Repeat task every 1 minute. Their start times should be 12:00:00 AM, 12:00:10 AM, 12:00:20 AM, 12:00:30 AM, 12:00:40 AM, and 12:00:50 AM.

Edit Trigger dialog

Silly, but it works.

  • 1
    I can confirm that this works, thanks for sharing this. Easiest solution I have seen. – Abela Jan 11 '16 at 1:05
  • 4
    See this Stack Overflow Answer for a convenient way to create many triggers for one task by exporting it to a text file. – Andre Jan 13 '16 at 15:31
  • 3
    Convenient? I think you mean manageable ;) – hahahahahahahaha Aug 25 '16 at 19:11
2

It's silly windows doesn't have this functionality built into Task Scheduler. However, it can be easily worked around with a simple powershell script.

 $i = 0
 for ($i=0; $i -le 4) 
   Start-Service -Name "servicename"  
   sleep 10
   $i++
 }

Save this as a *.ps1 file on your host. Then follow Adam C's task scheduler settings and schedule this to run every minute. This will start the service (which I named "servicename") every 10 seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.