Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to schedule a Windows task to run a script every minute. In most cases, the script doesn't need to execute anything and exists immediately. When the script needs to execute something, I want it to start the job as quick as possible, thus the one minute interval.

Now, the UI of the Windows Scheduler has become quite confusing in recent years, so I'm not sure what's the best way to run a task every minute (or 5 minutes ..) on Windows 2008 R2:

Scheduler

Is this the best way to schedule a task under Windows every minute? Is it reliable? Does it start directly after a machine is rebooted, or is it only started again at 12pm? Please note that I cannot use/write a custom service application for this, as I need it to be very portable.

share|improve this question
    
No it is not the best way. You should use a sleep or wait function in your script. –  Joseph Kern Aug 26 '09 at 15:48
add comment

3 Answers

up vote 4 down vote accepted

Yes, this service will run after reboot, you can verify it in the Task Scheduler service transaction log:

    Systemroot\SchedLgU.txt

    (where Systemroot is your windows installation folder)

If it's not working correctly (under XP, unsure about 2008 equivalent):

    
    Control Panel -> Administrative Tools -> Services -> Task Scheduler 

    Set to auto. 

2008 Documentation here, XP Documentation here

The task's schedule commences at the specified time, after that it executes based on the repetition parameters. The start time can be considered as "task installation" time, it is not part of the repetition parameters (except as a timer offset). Hope that makes sense!

share|improve this answer
    
I actually meant if the machine is rebooted, is the task triggered again directly after reboot, or is only again started at 12pm, as specified in the GUI? I need the task to run every minute, regardless of a machine reboot etc. –  Dennis G. Aug 26 '09 at 15:00
    
And, how can I very if a task has been executed? Is it logged somewhere in the Event Log? I cannot seem to find any log entries. Thanks. –  Dennis G. Aug 26 '09 at 15:03
    
Updated answer for clarification –  Andy Aug 26 '09 at 15:28
    
Thanks, that clarifies it. –  Dennis G. Aug 26 '09 at 15:35
add comment

I had this same requirement. In Server 2008, you can actually modify the Repeat task every: dropdown. By default the lowest value is "5 minutes", but you can simply type "1 minute" in there. You can verify this by looking at the Triggers tab and seeing that it says "... repeat every 00:01:00...". You can also try typing in "10 seconds" and you'll get an error telling you to choose something greater than 1 minute.

share|improve this answer
add comment

I am able to scheduled a task to repeat once per minute with the command line "schtasks". An example of the code is:

schtasks /create /sc minute /mo 1 /tn "Task Name" /tr c:\temp\filename.exe

The task does display in the Windows 2008 R2 GUI and runs once a minute. The task needs to be created and modified with the command line "schtasks" utility.

Unfortunately, Microsoft foolishly designed the Windows 2008 R2 task scheduler, dropping the flexible configuration found in Windows 2003's Task Scheduler, in favor of a few limited choices for intervals.

davephan

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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