0

Can anybody explain me, why the command "ls -gGh" (or "ls -lh", which just shows user and group info additionally) displays a completely different filesize compared to the command "ls --size --block-size=1024" for the file "/var/log/cron.log", but not for "/var/log/bkp_hmail_data.log"?

Same system (Cygwin on Win7), same machine, same folder, just different files.

$ /bin/ls -gGh /var/log/cron.log
-rw-r--r-- 1 54K  4. Mai 18:29 /var/log/cron.log
$ /bin/ls --size --block-size=1024 /var/log/cron.log
17256 /var/log/cron.log
$ /bin/ls -gGh /var/log/bkp_hmail_data.log
-rw-r--r-- 1 654K  4. Mai 01:32 /var/log/bkp_hmail_data.log
$ /bin/ls --size --block-size=1024 /var/log/bkp_hmail_data.log
656 /var/log/bkp_hmail_data.log

Thanks for any help

edit: BTW:

  • Windows explorer confirms the value of "ls -gGh" (54kB for cron.log)

  • du confirms the value of "ls --size --block-size=1024" (17256kB for the same cron.log)

crazy, or: what do I overlook?

schogol
  • 53
  • 11
  • Is `/var/log/cron.log` a file still opened by cron ? – matzeri May 04 '17 at 20:31
  • Does `/var/log/cron.log` have holes in it, i.e. is it a sparse file. Try `cat FILE | wc` to count the number of bytes found when reading the file. – Doug Henderson May 04 '17 at 22:32
  • @matzeri: no, cron.log is not opened anymore by cron – schogol May 05 '17 at 19:25
  • @Doug Henderson: yesterday, after not seeing a reaction to my post after a while, I deleted and recreated cron.log, so I can not test what you are suggesting. After deleting the original file, the problem was solved, but probably can reappear at any time, so thank you so much for your input, I will try then. (I already opened the original file in a hex editor before, and there were no holes to see, the file had exactly the number of bytes it was supposed to have when using "ls -gGh". Would holes be visible in a hexeditor?) – schogol May 05 '17 at 19:42
  • I believe holes may show as zero bytes depending on your hex editor. Cron may continue the log for a new session on a page or larger boundary. – Doug Henderson May 05 '17 at 19:46
  • Ok, there were no huge amounts of "00"-bytes, but I'll keep that in mind. Thanks a lot for your help! At the moment, my script is working as expected/required, but I'll keep an eye on it. Thank you again. – schogol May 05 '17 at 21:07
  • Also, see https://stackoverflow.com/questions/23789031/size-vs-ls-la-vs-du-h-which-one-is-correct-size – ewindes May 09 '17 at 21:04

0 Answers0