Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to schedule a task for every 5 minutes in windows command prompt?

I'm currently scheduling .bat files using Windows Task Scheduler. However, I want to do this using the Command Prompt's schtasks command. My batch file should run every five minutes and repeat its task every day.

like image 537
Yosuva Arulanthu Avatar asked Mar 04 '15 12:03

Yosuva Arulanthu


People also ask

How do I run a program every 5 minutes?

Go to Control Panel » Administrative Tools » Scheduled Tasks. Create the (basic) task. Go to Schedule » Advanced. Check the box for "Repeat Task" every 10 minutes with a duration of, e.g. 24 hours or Indefinitely.

How do I schedule a task in Command Prompt?

Start the Task Scheduler in Windows by using the PowerShell or Command Prompt. Open command prompt or PowerShell apps, enter the command taskschd. msc and then hit Enter the Task Scheduler will open immediately.

How do I run Task Scheduler every 1 hour?

To set the script to run hourly, we select the 'Repeat task…' option and enable it. We select the '1 hour' option, indicating that we wish for the task to execute on an hourly basis, and select the duration as indefinite under the duration option.


1 Answers

I don't have much experience with .bat file (and maybe what I am about to write is nonsence), but I was wondering if a GOTO and a delay can resolve your problem.

:label
<do stuff>
SLEEP 300
GOTO label

LE: Ok, I found something that might help you:

schtasks /create /sc minute /mo 5 /tn "TaskName" /tr \\scripts\whatever.bat

This line should do the trick. For more information you can visit https://technet.microsoft.com/en-us/library/cc772785(v=ws.10).aspx

like image 142
Cristian Marian Avatar answered Sep 18 '22 06:09

Cristian Marian