Click to See Complete Forum and Search --> : log files
henriksonj
09-27-2001, 04:06 PM
I know I should know this but I don't.. how do I reinitialize the log files in /var/logs?
thanks!!!!!
John H.
[ 27 September 2001: Message edited by: henriksonj ]
pbharris
09-27-2001, 05:09 PM
i just delete the ones that are there.
henriksonj
09-27-2001, 05:41 PM
Isn't it preferable to do something with /dev/null ?
I was trying to remember it.. xx.log>/dev/null or something?
thanks
X_console
09-27-2001, 09:28 PM
Not sure what you mean by reinitialize, but basically if you're missing logfiles, restarting syslogd should bring them back:
kill -HUP $(cat /var/run/syslogd.pid)
cabu1966
09-27-2001, 10:22 PM
Originally posted by henriksonj:
<STRONG>Isn't it preferable to do something with /dev/null ?
I was trying to remember it.. xx.log>/dev/null or something?
thanks</STRONG>
do you mean "cp /dev/null /var/log/filename.log". I use this to clear my log files.
henriksonj
09-28-2001, 10:56 AM
That was it.. don't know what I was doing wrong that kept that cp /dev/null from working.. thanks though!!!
Craig McPherson
09-28-2001, 06:39 PM
You really shouldn't delete log files while a process has them open for writting. Because the file descriptor will have changed, the program won't be able to write to them anymore without restarting and re-opening the file. Re-creating a file after deleting it won't help, because the old file descriptor still won't work, nor will copying /dev/null over the file (which actually deleted the file and creates a new one) -- the process will continue to run, but will quietly dump its log data into the ether until it restarts or otherwise realizes its log file has changed.
If you want to clear the contents of a file, you can do this:
cat /dev/null > filename
That'll leave the file intact, and any files that have it open will still be able to write to it, but it'll remove all data from the file.
Or just delete the log file and restart the daemon that had it open -- it'll recreate the log file.
You really should just use logrotate for handling your logs, though. It's a lot more elegant.
[ 28 September 2001: Message edited by: Craig McPherson ]