From Wsms
back to notes
cron and logrotate
A sample /etc/crontab file:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
Sample contents of an /etc/cron.daily directory:
total 108
-rwxr-xr-x 1 root root 133 Feb 12 2006 00webalizer
-rwxr-xr-x 1 root root 276 Feb 10 2006 0anacron
lrwxrwxrwx 1 root root 39 Oct 16 09:38 0logwatch -> /usr/share/logwatch/scripts/logwatch.pl
-rwxr-xr-x 1 root root 44 Mar 8 2006 beagle-crawl-system.cron
-rwxr-xr-x 1 root root 1042 Feb 10 2006 certwatch
-rwxr-xr-x 1 root root 118 Feb 10 2006 cups
-rwxr-xr-x 1 root root 180 Feb 11 2006 logrotate
-rwxr-xr-x 1 root root 418 Feb 11 2006 makewhatis.cron
-rwxr-xr-x 1 root root 137 Feb 11 2006 mlocate.cron
-rwxr-xr-x 1 root root 2133 Nov 23 2004 prelink
-rwxr-xr-x 1 root root 114 Feb 12 2006 rpm
-rwxr-xr-x 1 root root 100 Feb 25 2006 tetex.cron
-rwxr-xr-x 1 root root 290 Feb 12 2006 tmpwatch
-rwxr-xr-x 1 root root 158 Mar 6 2006 yum.cron
Sample /etc/logrotate.conf file:
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own lastlog or wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
/var/log/lastlog {
monthly
rotate 1
}
# system-specific logs may be configured here
Sample contents of the /etc/logrotate.d directory:
acpid cups httpd mgetty mysqld named ppp psacct rpm samba squid syslog tux yum
Sample /etc/logrotate.d/syslog file:
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}