Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
JelloOfTheMoon
- Posts: 11
- Joined: 30 Jul 2013 20:07
#1
Post
by JelloOfTheMoon » 04 Aug 2013 10:19
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?
-
aGerman
- Expert
- Posts: 4722
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 04 Aug 2013 11:00
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
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#3
Post
by foxidrive » 04 Aug 2013 11:40
use this instead
ping -n 600 localhost >nul
or use the TIMEOUT command.
-
JelloOfTheMoon
- Posts: 11
- Joined: 30 Jul 2013 20:07
#4
Post
by JelloOfTheMoon » 04 Aug 2013 12:18
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.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#5
Post
by foxidrive » 04 Aug 2013 12:25
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:
-
JelloOfTheMoon
- Posts: 11
- Joined: 30 Jul 2013 20:07
#6
Post
by JelloOfTheMoon » 04 Aug 2013 12:41
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
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#7
Post
by foxidrive » 04 Aug 2013 12:49
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)
-
JelloOfTheMoon
- Posts: 11
- Joined: 30 Jul 2013 20:07
#8
Post
by JelloOfTheMoon » 04 Aug 2013 13:18
That fixed it. Thanks for the disproportionate amount of time that was attributed to my problem