[Linux-disciples] Deleting the first N lines of a file

Stephen R Laniel steve at laniels.org
Thu Feb 9 17:20:02 EST 2006


On Thu, Feb 09, 2006 at 11:42:20AM -0500, Stephen R Laniel wrote:
> Good point. That's going to be part of my testing: whether
> there's some problem with file locking when Apache is trying
> to write to the end while I'm deleting from the beginning.

I think that editing the file in place causes problems. I
ran a little test where

1) wget is hammering away at a test web server, and
2) the web server is running the aforementioned 'sed -i'
   command on a cron job

What happened was that Apache stopped writing out to the
access log as soon as the cron job fired off. Wget kept
hammering the server and getting pages back, but none of the
hits ended up in the access log. I think that sed opened the
file for reading and writing, and Apache couldn't get a lock
on the file, so it stopped writing.

I wish there were some more granular way to lock a file. *I*
know that the sed command is not going to touch the same
stuff that Apache is touching: sed is touching the beginning
of the file, and Apache's touching the end, and never the
twain shall meet. But I don't think there's any way to lock
the file that will keep both Apache and sed happy.

-- 
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060209/70fd9ba4/attachment.pgp


More information about the Linux-disciples mailing list