Is there a way to schedule a task (.bat) through the command line that runs every five minutes daily?
I also want it to run even if the user isn't logged on. What is the exact command line syntax?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
You can do this with the following command:
schtasks /create /tn "MyTask" /sc minute /mo 5 /tr "MyTask.cmd"
/create- create a new scheduled task
/tn "MyTask"- give the task as name
/sc minute- schedule the task with a frequency in minutes
/mo 5- and modify the freqency to be every 5 minutes
/tr "MyTask.cmd"- run the command
Source schtasks - Create / edit a Scheduled Job/Task.
You can try to use the following:
SchTasks /Create /SC MINUTE /MO 5 /SD 12/31/9999 /TN "My Task" /TR %~dp0%~n0%~x0 /ST 23:59:59
as DavidPostill said:
/create - create a new scheduled task /tn "My Task" - give the task as name /sc minute - schedule the task with a frequency in minutes /mo 5 - and modify the frequency to be every 5 minutes /sd 12/31/9999 - date in which should begin the task mm/dd/yyyy /st 23:59:59 - start date in which is going to start the task in 24 hour format /tr "MyTask.cmd" - run the command MyTask.cmd
in my case for "/tr" I used the following:
%~dp0 - path (location) of the current file %~n0 - current file name %~x0 - extension of the current file