|
Answer» I was wondering if SLEEP is the best method for a 10 minute delay or if there is anything else out there that works better for longer than what sleep was really created for delays in batch files for say 10, 15, 30 minutes etc?
I have a batch that executes 6 processes using START for each process to execute. On step 3 I have to wait 10 minutes for the program in Step 2 to be at the correct rested state to take step 4's process. If Step 4 executes too soon, it will likely corrupt the SQL database in Step 2 for our Cheftec Software.
I cant think of any other fix to this other than CREATING a LONG delay so that I am 99.9% confident that Step 2 is done and resting, so that I can process the additional batched SQL instructions.
All suggestions welcome. Just thinking that there might be a better means than using SLEEP which I think was designed for shorter delays like 30 sec etc.Well, Windows Vista and Above have the TIMEOUT command but you also need to understand two others things about batch.
Batch files do sequential processing. That means it does not move onto the next command until the previous command has COMPLETED. The only exception to that is if you launch another process with the START command. But if you use the START command you can also use the WAIT switch to keep it from moving on to the next process until the current one has completed. You also don't need to use the START command at all to launch another process.
So here are some batch file examples:
If I want to launch Notepad and then launch calculator after notepad is closed, I could do two ways.
If you put this code into a batch file, Calculator will not launch until Notepad has closed.
Code: [Select]"%windir%\system32\notepad.exe" "%windir%\system32\calc.exe"You can also do it like this as well.
Code: [Select]start "" /wait "%windir%\system32\notepad.exe" start "" /wait "%windir%\system32\calc.exe"Same affect just DIFFERENT code. The next process will not start until the previous process has completed.
Quote from: nixie on DECEMBER 23, 2011, 09:46:11 AM I was wondering if SLEEP is the best method for a 10 minute delay or if there is anything else out there that works better for longer than what sleep was really created for delays in batch files for say 10, 15, 30 minutes etc?
Why do you think that whichever version of sleep.exe you have was "created for" certain lengths of delay? It waits for the number of milliseconds or seconds (according to version) that you tell it to wait. It doesn't care if it is 30 seconds or 300 or 3000.
|