Hello,
I'm having a serious problem with a batch file that does simple things like moving files to another folder, copying several files into a single file, and then moving these files to different folders.
Then, I have a planified task (Windows server 2008) that executes this batch file every 10 minutes.
Normally, it takes just 1 minute to do all its job. And the output file (cli.txt) size is about 60 Ko. But sometimes, not always, just occasionally, I can't stop it. The output file is always occupied by "System" process and it gets bigger and bigger without stopping at all. I dare not kill the "System" process. Eventually I have to shut down the server.
Here is my batch file without a word changed:
x:
cd "\interface\Exp Clients"
move "*.txt" "x:\interface\Exp Clients\TEMP\"
cd TEMP
if exist *.txt (type *.txt >> cli.txt)
set dateheure=%date:~0,2%-%date:~3,2%-%date:~6,4%_%time:~0,2%h%time:~3,2%min%time:~6,2%s
set dateheure=%dateheure: =%
copy "cli.txt" "x:\interface\Exp Clients\HISTO\cli_%dateheure%.txt"
move "cli.txt" "x:\interface\Exp Clients\"
move "*.txt" "x:\interface\Exp Clients\HISTO\"
Any idea why this happens? Thanks!
Lea
file getting bigger (over 7 Go) and can't stop
Moderator: DosItHelp
Re: file getting bigger (over 7 Go) and can't stop
Change this line:
To this:
because the first one is also typing the file that is being created.
Code: Select all
if exist *.txt (type *.txt >> cli.txt)
To this:
Code: Select all
if exist *.txt (type *.txt >> cli.tmp & move cli.tmp cli.txt)
because the first one is also typing the file that is being created.
Re: file getting bigger (over 7 Go) and can't stop
You basically created a cyclical process.
Re: file getting bigger (over 7 Go) and can't stop
OK. I think I understand. cli.txt meets the condition *.txt, right?
I will test foxidrive's suggestion.
Thanks a lot, both of you!
Lea
I will test foxidrive's suggestion.
Thanks a lot, both of you!
Lea
Re: file getting bigger (over 7 Go) and can't stop
There also seems to be possible problems using multiple calls to %TIME% and no need for the TEMP directory, (little point in moving all of your text files twice)!Maybe COPY could prove a better solution than TYPE and also if you want the cli.txt to be included as part of the next run, then you may need to ensure that it is named in such a way as to be the first one typed from the wildcard, perhaps naming it _cli.txt may be sufficient.
Code: Select all
@Echo Off
SetLocal
(Set BD=X:\Interface\Exp Clients)
If Not Exist "%BD%\*.txt" Exit/B
If /I "%CD%" NEq "%BD%" PushD %BD%
(Set D=%DATE%)
(Set H=%TIME%)
(Set DH=%D:~,2%%D:~3,2%-%D:~6,4%_%H:~,2%h%H:~3,2%min%H:~6,2%s)
If Not Exist HISTO\ MD HISTO
Type *.txt>>"HISTO\cli_%DH: =%.txt"
Move *.txt HISTO
Copy "HISTO\cli_%DH: =%.txt" "%BD%\cli.txt"