Schedule Windows Task every minute

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.

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.


Solution 1:

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!

Solution 2:

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.

Solution 3:

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