Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Console logfile got zipped while process was running

0 views
Skip to first unread message

Teddy

unread,
Jul 29, 2008, 11:08:45 AM7/29/08
to
Hello,

Our process creates two logfiles. One is console log file and other
is
what we called process log file which contains some debug and
informatic messages.

Sometime this files get so huge that sys admin is forced to run
compression script which compresses this file and replaced these
files
with zipped one.
But this doesnt affect process it keep on running and keep on logging
to some garbage file descriptor.I am calling this as garbage because
there is no physical file associated with that descriptor.

Could anybody explain me how this happens? Process didnt generate any
kinf of error that for sure. In fact once I ran tail on console log
file in and it keep on showing me data even though console log file
got zipped.

Thanks in advance

Barry Margolin

unread,
Jul 30, 2008, 1:02:14 AM7/30/08
to
In article
<b34c9042-053d-4003...@p25g2000hsf.googlegroups.com>,
Teddy <neeraj...@gmail.com> wrote:

The OS doesn't actually remove the file from disk as long as there are
any open file descriptors referring to it. It just removes the
directory entries that point to it.

As an analogy, suppose you were a librarian and were planning on
throwing out a book, so you remove its entry from the card catalog. But
if someone had already reserved it, you wouldn't throw it out
immediately; you'd keep it on the shelf until they check it out, and
toss it in the garbage when it's returned.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Teddy

unread,
Jul 30, 2008, 3:52:19 AM7/30/08
to
Thanks for explanation. I understood why process keep on running fine.

I have some more questions.
Where does all log message which process keep on logging goes to ?
I mean Consider case where I ran tail on log file and compression
script zipped that file.
I still could see log messages. I guess tail must have its buffer
which it keep on updating from files contents whenver
that file status changes. How does tail come to know that file has
been updated when there is no such file on disk ?

Also why system call which writes this message to log files doent
throw any error ?

Thanks in advance

Barry Margolin

unread,
Jul 30, 2008, 11:17:00 PM7/30/08
to
In article
<579aa562-6ad2-4cd6...@e53g2000hsa.googlegroups.com>,
Teddy <neeraj...@gmail.com> wrote:

> Thanks for explanation. I understood why process keep on running fine.
>
> I have some more questions.
> Where does all log message which process keep on logging goes to ?
> I mean Consider case where I ran tail on log file and compression
> script zipped that file.
> I still could see log messages. I guess tail must have its buffer
> which it keep on updating from files contents whenver
> that file status changes. How does tail come to know that file has
> been updated when there is no such file on disk ?

Tail uses fstat(), which asks the status of the disk file that the open
fd points to.

Actually, GNU tail has an option, --follow=filename. In this case it
calls stat() on the original filename rather than fstat() on the
descriptor. This is useful for logfiles that get rotated, so that tail
will skip to the new version.

> Also why system call which writes this message to log files doent
> throw any error ?

Once a file is opened, everything gets written through the descriptor.
It doesn't matter whether the filename continues to exist.

Returning to my library analogy, suppose they throw out the catalog card
for the book after you've borrowed it. You can keep reading the book,
and you can also write in the margin. The catalog is only used to find
the book initially, not to use it once you've found it.

0 new messages