Page 1 of 1
Loops too fast
Posted: 04 Aug 2013 10:19
by JelloOfTheMoon
My code for backing up a certain set of files works perfectly, except it loops every three seconds when I need it to loop every five minutes.
Code: Select all
@TITLE Backer-upper
:loop
<server.PROPERTIES (
for /l %%i in (1 1 4) do set /p "="
set /p "st="
)
for /f "tokens=1* delims==" %%i in ("%st%") do set st=%%j
set worldname=%st%
SET timestamp=%date:/=-%-%time::=-%
XCOPY "%worldname%\*" "%~dp0\backups\worlds\%worldname%_backup_%timestamp%" /i /s
PING 1.1.1.1 -n 1 -w 600000 > NUL rem the large number = number of secs btw backups (currently 5 min)
goto loop
What is wrong/what needs to be changed?
Re: Loops too fast
Posted: 04 Aug 2013 11:00
by aGerman
rem the large number = number of secs btw backups (currently 5 min)
No, it isn't. 600000 ms = 600 s = 10 min.
The first question: Is 1.1.1.1 a reachable IP address in your network? If so you can't use it!
Try to use 192.0.2.0 instead (see
http://www.rfc-editor.org/rfc/rfc5737.txt).
Regards
aGerman
Re: Loops too fast
Posted: 04 Aug 2013 11:40
by foxidrive
use this instead
ping -n 600 localhost >nul
or use the TIMEOUT command.
Re: Loops too fast
Posted: 04 Aug 2013 12:18
by JelloOfTheMoon
The idea was to have it timeout after a certain amount of time because it couldn't reach the ip address.
The line fox gave me just bumped up the time to eight seconds.
Re: Loops too fast
Posted: 04 Aug 2013 12:25
by foxidrive
JelloOfTheMoon wrote:The idea was to have it timeout after a certain amount of time because it couldn't reach the ip address.
The line fox gave me just bumped up the time to eight seconds.
I doubt very much that you ran that command in 8 seconds

unless you can't run this command successfully:
Re: Loops too fast
Posted: 04 Aug 2013 12:41
by JelloOfTheMoon
I don't think that line is the problem. I took out the XCOPY line and now it does it several times each second
Edit: I created a new batch file with:
and it works completely fine. It's something else in the batch file, not your line.
Edit2: I've stripped it down to this to troubleshoot:
Code: Select all
@TITLE Backer-upper
:loop
echo f| XCOPY "server.PROPERTIES" "%~dp0\backups\server_properties"
PING -n 30 localhost> NUL
goto loop
@pause
Re: Loops too fast
Posted: 04 Aug 2013 12:49
by foxidrive
JelloOfTheMoon wrote:Code: Select all
PING 1.1.1.1 -n 1 -w 600000 > NUL rem the large number = number of secs btw backups (currently 5 min)
What is wrong/what needs to be changed?
You cannot have a REM command at the end of a command, unless you use an & before the REM to separate them.
Code: Select all
ping -n 600 localhost>nul & REM the large number = number of secs btw backups (currently 5 min)
Re: Loops too fast
Posted: 04 Aug 2013 13:18
by JelloOfTheMoon
That fixed it. Thanks for the disproportionate amount of time that was attributed to my problem