I have made a batch script for backup recently. Somewhere in the middle of script I'll have to wait for some time to be reached and then resume the next line of the script. I've scheduled the script at 4:00PM and after the wait command the next line should start at exactly 5:30PM. I thought of using SLEEP
command but it's not sure that the commands used before the wait command will end up at certain time(due to inconsistent file sizes) but it's sure that they will be done by 5:00 or 5:10 and next it should execute wait command which waits for certain system clock. I'm checking if there is any command that waits or sleeps until the time specified reaches the system time and resumes there after. Anybody came across this situation and how was that resolved?
You're using two tags, WinXP and Server-2008-R2, so I'm not sure which environment you're running in.
Both environments have a command called
schtasks
that allows setting up scheduled tasks from the command-line, though the capabilities of this tool varies with the platform. It will allow you to set up a one-time task that will call the remainder of your script. It'll have to be in a separate file, but it'll get executed a single time at 5:30pm.XP Syntax: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx
Server-2008 Syntax: http://technet.microsoft.com/en-us/library/cc725744%28WS.10%29.aspx#BKMK_once
Probably not the best way to do this, but here goes:
I don't know about any command to wait for a specific time but you might find some Googling for it. We solve similar issues by chopping the batch files into separate parts and scheduling them individually.