par rodolphedj » 11 Mai 2004 13:25
How do I clear log files?
Generally, you can just use the ">" to empty a log file. For example, to clear out /var/adm/syslog, just use:
> /var/adm/sylog
That will empty the file while leaving ownerships and permissions intact.
Sometimes, however, you have a program that keeps the file open while it writes to the log. In such a case, you may need to stop the program, clear the log, and restart.
You can easily check to see if any process is using a file with "fuser":
fuser /var/adm/syslog
will return the pid of syslog. You can combine all this:
ps -p `fuser /var/adm/syslog`
(It's not necessary to stop the syslogd process when clearing syslog)
Rodolphe