Tuesday, June 5, 2007

Recycling the logs in Fedora 6

Recycling of the log files

In Fedora, most daemons save their logs in /var/log/. If they aren't periodically recycled (meaning throw away or archived), they can potentially grown until they fill the disk.

In order to avoid that, if your daemon doesn't already has it, create a file like this in /etc/logrotate.d/, or add it to /etc/logrotate.conf.

All Fedora official RPM packaged daemons already have this.

# recycles the log file for myDaemon and myOtherDaemon
/var/log/myDaemon.log /var/log/myOtherDaemon.log {
notifempty
size 300k
create 0600 root root
}

Note that the new file is being created as root. Change that if your daemon runs as another user or it wont be able to write to the file.

No comments: