Hmmm  Same deal.  Here is what I am doing.

#testtime > numfile &
#trunclog numfile


here are the scripts:

[bhughes@compaq2 bhughes]$ less testtime
#! /bin/sh
echo 'setting num to 0'
i=1
while [ $i -lt 2000 ] ; do

  echo $i
  i=`expr $i + 1`
done


[bhughes@compaq2 bhughes]$ less trunclog
#! /bin/sh
#  trunclog
echo 'about to truncate' $1
if [ -f $1 ]
then
  cp $1 $1.bak
#  cat /dev/null > $1
  echo >$1
else
  echo 'file not found'
fi

output of ls after running both files

[bhughes@compaq2 bhughes]$ ls -l
total 28
-rw-rw-r--   1 bhughes  bhughes      8905 Jan 21 11:37 numfile
-rw-rw-r--   1 bhughes  bhughes      8425 Jan 21 11:37 numfile.bak
-rw-rw-r--   1 bhughes  bhughes        35 Jan 17 16:18 testfile
-rwx------   1 bhughes  bhughes       104 Jan 20 11:24 testtime
-rwx------   1 bhughes  bhughes       153 Jan 21 11:30 trunclog

I run trunclog befor the background job is finished and after
truncation, numfile has a whole shitload of @ symbols on the same line
as the first number

ls after removing all @s

[bhughes@compaq2 bhughes]$ ls -l
total 32
-rw-rw-r--   1 bhughes  bhughes      8905 Jan 21 11:37 numfile
-rw-rw-r--   1 bhughes  bhughes      8425 Jan 21 11:37 numfile.bak
-rw-rw-r--   1 bhughes  bhughes       480 Jan 21 11:41 numfile.clean
-rw-rw-r--   1 bhughes  bhughes        35 Jan 17 16:18 testfile
-rwx------   1 bhughes  bhughes       104 Jan 20 11:24 testtime
-rwx------   1 bhughes  bhughes       153 Jan 21 11:30 trunclog

now that I look at it it looks like the file size is kept the same and
padded with these @ symbols.  since the total of the clean file and the
bak file equals the size of new numfile. 

Yep, just ran testtime all the way though without truncating and the
size is indeed 8905.  shell must be keeping track of where it is writing
on the disk and keeping going?  I don't pretend to know enough about
what is happening but it is interesting.  I'll dig into the logrotate
doc and see if I can fire off logrotate to truncate the file before it
is finished.

Any ideas?

Bret

Tom Gilbert wrote:
> 
> * Bret Hughes ([EMAIL PROTECTED]) wrote:
> > Good to know also.  I tried the cat /dev/null > logfile technique and
> > while I did not loos any data there is about 4K or so of garbage at the
> > begining of the logfile.  In less it shows up as all '@' (noquotes)
> > symbols.
> >
> > Does not look good for the cat  dev/null > technique.  I am going to use
> > the logrotate any way but was hoping to learn something.  I guess I did,
> > just not what I was hoping :-)
> >
> > Thanks again
> >
> > Bret
> 
> That shouldn't happen. Odd. Well, if that doesn't work, even simpler
> is:
> 
> $ echo > logfile
> 
> Tom.
> --
>             .-------------------------------------------------------.
>     .^.     | Tom Gilbert, England | [EMAIL PROTECTED] |
>     /V\     |----------------------| www.tomgilbert.freeserve.co.uk |
>    // \\    | Sites I recommend:   `--------------------------------|
>   /(   )\   | www.freshmeat.net www.enlightenment.org slashdot.org  |
>    ^^-^^    `-------------------------------------------------------'
> 
> --
> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> as the Subject.
begin:vcard 
n:Hughes;Bret 
tel;fax:918.587.0131
tel;work:918.587.0131
x-mozilla-html:FALSE
url:www.elevating.com
org:Elevating Communications Inc
adr:;;PO Box 1323;Tulsa;OK;74101-1323;USA
version:2.1
email;internet:[EMAIL PROTECTED]
title:Chief Solutionist/President
x-mozilla-cpt:;19888
fn:Bret  Hughes
end:vcard

Reply via email to