Hi,
Recently I saw that my syslog and daemon.log files in /var/log directory are huge (7G each). They were eating up all the diskspace in my / directory. So to save some space I truncated the daemon.log using the truncate command and restarted the laptop. There were a lot of errors while shutting down but eventually things became normal.
So far so good.
Now I was looking about limiting size of logfiles. And found that I can use logrotate as a cron job to do so (
http://www.thegeekstuff.com/2010/07/logrotate-examples/) As per the guide, I poked around in my configurations. Here is how things look:
Code:
somesh@creativision:/etc/logrotate.d$ crontab -l
no crontab for somesh
Code:
somesh@creativision:/etc/logrotate.d$ cd /etc/cron.daily/
somesh@creativision:/etc/cron.daily$ ll
total 76
-rwxr-xr-x 1 root root 311 Mar 9 2008 0anacron
-rwxr-xr-x 1 root root 14799 Apr 15 2011 apt
-rwxr-xr-x 1 root root 314 Dec 4 2008 aptitude
-rwxr-xr-x 1 root root 502 Nov 20 2007 bsdmainutils
-rwxr-xr-x 1 root root 256 Apr 26 2011 dpkg
-rwxr-xr-x 1 root root 4109 May 12 2011 exim4-base
-rwxr-xr-x 1 root root 7623 Jul 9 21:29 google-chrome
lrwxrwxrwx 1 root root 45 Jun 26 08:31 google-talkplugin -> /opt/google/talkplugin/cron/google-talkplugin
-rwxr-xr-x 1 root root 580 Sep 23 2008 htdig
-rwxr-xr-x 1 root root 89 Oct 8 2008 logrotate
-rwxr-xr-x 1 root root 1335 Jan 2 2011 man-db
-rwxr-xr-x 1 root root 606 Nov 4 2009 mlocate
-rwxr-xr-x 1 root root 1154 Nov 22 2009 ntp
-rwxr-xr-x 1 root root 249 Feb 15 2011 passwd
-rwxr-xr-x 1 root root 3594 Dec 18 2010 standard
Code:
somesh@creativision:/etc/cron.daily$ cat logrotate
#!/bin/sh
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf
Code:
somesh@creativision:/etc/logrotate.d$ cat /etc/logrotate.conf
# 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
# packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
# system-specific logs may be configured here
Code:
somesh@creativision:/etc/logrotate.d$ ll
total 52
-rw-r--r-- 1 root root 173 Apr 15 2011 apt
-rw-r--r-- 1 root root 79 Dec 4 2008 aptitude
-rw-r--r-- 1 root root 135 Feb 24 2010 consolekit
-rw-r--r-- 1 root root 248 Mar 2 2010 cups
-rw-r--r-- 1 root root 232 Apr 26 2011 dpkg
-rw-r--r-- 1 root root 146 Sep 30 2008 exim4-base
-rw-r--r-- 1 root root 126 Sep 30 2008 exim4-paniclog
-rw-r--r-- 1 root root 94 May 16 2008 hibernate
-rw-r--r-- 1 root root 157 Nov 16 2010 pm-utils
-rw-r--r-- 1 root root 94 Aug 8 2010 ppp
-rw-r--r-- 1 root root 559 Jul 13 22:51 rsyslog
-rw-r--r-- 1 root root 222 Feb 3 2010 squid
-rw-r--r-- 1 root root 114 Oct 2 2006 unattended-upgrades
Code:
somesh@creativision:/etc/logrotate.d$ cat rsyslog
/var/log/syslog
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
postrotate
invoke-rc.d rsyslog reload > /dev/null
endscript
}
/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
rotate 4
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog reload > /dev/null
endscript
}
My questions are:
1. As far as I know, even if my list of crontab (crontab -l) shows nothing, the files under cron.daily directory work as a daily cronjob. Is that right?
2. Is the daily cron of logrotate looking into all the files in logrotate.d directory ("include /etc/logrotate.d" line in logrotate.conf) and rotating the logs accordingly? Or is it just rotating wtmp and btmp?
3. It seems to me that if I add a line "size 1000000k" in the rsyslog file in logrotate.d, the size of these log files will be limited to 1G. Now will that hamper the performance of my laptop any way?
TIA,