Larry Ploetz wrote:
On 1/6/09 1:50 PM, John McKown wrote:
I've got a small problem. I have a daemon which I cannot easily restart
because it is production and people are using it. The daemon is started
with something like:

daemon args>>daemon.log

The file "daemon.log" is getting very huge. The correct way to fix
this is
to stop the daemon, "mv" or "rm" the "daemon.log", then restart the
daemon. But I have a vague memory that it is sometimes possible to
"reset"
a file to "empty" simply by doing a:


daemon.log


You're probably thinking of "> daemon.log" to truncate a file.

and that will, at times, work even if the daemon is not restarted. Is my
memory correct? Or is that some sort of "special case" which does not
apply when bash does a>>  redirect of stdin?


No, append isn't a special case.

We plan to fix this by "not doing that!", but instead piping the stdout
from the daemon to a process called "cronolog" which works by
automatically changing the output file at midnight by changing the "date
portion" of the log name.


I believe some people don't think this is kosher, but I like:

bzip2 -c daemon.log > daemon.log.$(date +%Y%m%d).bz2 && > daemon.log

but if daemon keeps daemon.log open, daemon.log will become a sparse
file the next time daemon writes to it. A sparse file doesn't take up
any disk space, in this case, except what's subsequently written to it
by daemon. You have to remember not to copy the first line of daemon.log
if you do this again (e.g., tail +2 daemon.log | ..., or if you want to
be more efficient:

I think there exist these problems:
1. Unwritten data held in a buffer may exceed your arbitrary one or two
lines. It would be safer to live with that, either ignoring it or
programming around it depending on the significance of the log.
2. I was concerned about loss of data, but atm I don't see how it would
happen.

In addition to Ronald's suggestion, one can also run the messages
through logger, part of the syslog package.. However, both ideas require
a restart.


-- spambait
1aaaa...@coco.merseine.nu  z1aaaa...@coco.merseine.nu
-- Advice
http://webfoot.com/advice/email.top.php
http://www.catb.org/~esr/faqs/smart-questions.html
http://support.microsoft.com/kb/555375

You cannot reply off-list:-)

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to