Page 1 of 1

DIR command not Refreshed

Posted: 18 Dec 2013 08:55
by Yossi Moses
Dear friends
The DIR command doesn't read refreshed real values of a folder.
If I have a very dynamic file that grows all the time, DIR gives any size, next DIR gives the same size until I go to the folder and press F5, then DIR gives a new bigger size.
Any ideas how to refresh from Command-Line?
Thanks
Yossi Moses

Re: DIR command not Refreshed

Posted: 18 Dec 2013 13:55
by penpen
I couldn't reproduce your result: The dir command is always updating:

Code: Select all

:: cmd.exe 1, same result even if replaced this dos cmd by an exe that grows extreme fast.
Z:\>for /L %a in (1,1,0x0FFFFF) do ((echo a) >> a.txt)
...
...
...

Code: Select all

:: cmd.exe 2
Z:\>for /L %a in (1,1,20) do dir a.txt

Z:\>dir a.txt
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: F4EE-FCFD

 Verzeichnis von Z:\

18.12.2013  20:37             2.835 a.txt
               1 Datei(en),          2.835 Bytes
               0 Verzeichnis(se),  9.785.974.784 Bytes frei

Z:\>dir a.txt
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: F4EE-FCFD

 Verzeichnis von Z:\

18.12.2013  20:37             2.838 a.txt
               1 Datei(en),          2.838 Bytes
               0 Verzeichnis(se),  9.785.974.784 Bytes frei

Z:\>dir a.txt
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: F4EE-FCFD

18.12.2013  20:37             2.844 a.txt
               1 Datei(en),          2.844 Bytes
               0 Verzeichnis(se),  9.785.974.784 Bytes frei

...
...
...

Z:\>dir a.txt
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: F4EE-FCFD

 Verzeichnis von Z:\

18.12.2013  20:37             2.931 a.txt
               1 Datei(en),          2.931 Bytes
               0 Verzeichnis(se),  9.785.974.784 Bytes frei

Z:\>
Maybe buffering reduces the amount of single file update in your case.

penpen

Re: DIR command not Refreshed

Posted: 18 Dec 2013 18:24
by foxidrive
In later versions of Windows when a file is being created then it may not show the increasing filesize like XP did.

Re: DIR command not Refreshed

Posted: 19 Dec 2013 11:35
by Yossi Moses
Thank you all
I tried it on XP and Win7, I ran in 2 separated command-line windows:
C:\>FOR /L %i IN (1, 1, 1000000) DO ECHO.X>> TEST.TXT
And
C:\NET>FOR /L %i IN (1, 1, 10000) DO DIR C:\TEST.TXT | FIND "TEST.TXT" >> DIR.TXT
And I got in Dir.TXT

12/19/2013 19:17 1,551 TEST.TXT
12/19/2013 19:17 1,563 TEST.TXT
12/19/2013 19:17 1,572 TEST.TXT
12/19/2013 19:17 1,590 TEST.TXT
12/19/2013 19:17 1,602 TEST.TXT
12/19/2013 19:17 1,614 TEST.TXT

And so on.
So, I don't know to create the situation, but in our servers the problem exists.
Thank you both very much
Yossi moses

Re: DIR command not Refreshed

Posted: 19 Dec 2013 13:53
by Sponge Belly
Hi Yossi, :-)

Try the following:

Code: Select all

type dynamic-file.log >nul
dir dynamic-file.log


A tip I picked up from ss64.com’s page on the type command.

Hope this helps!

- SB

Re: DIR command not Refreshed

Posted: 19 Dec 2013 14:16
by penpen
Only if Sponge Bellys suggestion does not solve your problem:
Maybe the problem could be solved by creating an c++ program, that checks the filesize by using the function GetFileSize.

If this function doesn't return the real value then i'm out of ideas, but
maybe the following list (that may be incomplete) helps you finding the issue,
although the given solutions may not be realizeable as it reduces the servers capabilities.
Possible causes -> and possible solutions:
- activated file cache -> disabled it (optimize for quick removal, or something like that)
- unsynchronized shared folder -> synchronize it (don't know the exe that does it),
- Volume Shadow Copy Service (VSS) -> disable it (may not be wanted by admin)
- raid side effect on faulty hardware, maybe possible, but i never have seen it -> (search for a defective hdd and replace it)
- mixed oses on server(s) / client(s) -> update server/client Software (SAMBA, ...)

penpen