Run command in specified time period

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Run command in specified time period

#1 Post by mohdfraz » 02 Jul 2011 23:38

Hi K,

I want this command " copy *.log d:\log " to run in batch file from 10:00am to 1:00pm and from monday to friday. Once this time is over the batch file keep monitoring time to re-start this copy command when it comes in the specified time period.

Thanks in advance

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Run command in specified time period

#2 Post by Ed Dyreen » 03 Jul 2011 00:20


You can use the sheduler to do this:

Code: Select all

schtasks /?
or

Code: Select all

at /?
Beware though, both methods have their advantages and disadvantages :!:

Code: Select all

   set "FullPath.SOURCE=!FullPath.PRGM3TH!\SYS\CFG\SchTasks"

   set "?=1sthMonth.CMD"    &set /p "?=  :/ !?!    "<nul
   ::(
      at 00:00 /interactive /every:1 "!FullPath.SOURCE!\!?!"
   ::)

   set "?=Saturday.CMD"    &set /p "?=  :/ !?!    "<nul
   ::(
      at 00:00 /interactive /every:za "!FullPath.SOURCE!\!?!"
   ::)
If you are writing a 'smart' batch, these system variables could be helpfull:

Code: Select all

echo.%DATE%
echo.%TIME%

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Run command in specified time period

#3 Post by mohdfraz » 03 Jul 2011 01:34

Actually windows or dos Scheduler task running is not good for my situation. I want to check Time and run command or else. check this below example batch file code the end IF line i need to work out in dos language.

Example;
======================================================================
:RunMycommands
copy *.log d:\
ren *.log a.txt
etc....

:Loop
If time greater than 8:00 and less than 16:00 then Goto RunMyCommands Else Goto Loop
======================================================================

the commands i want to run continuously once after they finish and during all day in the specified time.

Post Reply