Friday, February 23. 2007What the hell is rotating my mail.log?I want to keep track of the spam scores that show up in my /var/log/mail.log on my Debian Etch machine. My idea was to run a shell script grep’ing the wanted info out of the mail.log right before that file is to be rotated. logrotate provides configuration options for how and when log files should be rotated. This includes a possibility to run a script right before and after the rotation is done. So, I created a configuration /etc/logrotate.d/mail like
CODE: /var/log/mail.log /var/log/mail.info {
...
sharedscripts
prerotate
/usr/local/sbin/extract-spamscores
endscript
postrotate
/etc/init.d/sysklogd reload-or-restart
endscript
}
sysklogd is Debian’s package containing syslogd and klogd. The syslog itself already cares for rotating the basic log files, and this includes /var/log/mail.{log,info,warn,err}. sysklogd contains the cron-jobs /etc/cron.daily/sysklogd and /etc/cron.weekly/sysklogd, both of which contain logic for rotating the system’s log files. To obtain the list of the log files, the command syslogd-listfiles is issued in both of the scripts—the weekly script uses the option --weekly. When I issue syslogd-listfiles, I only get /var/log/syslog as answer, whereas with --weekly I get:
CODE: # syslogd-listfiles --weekly
/var/log/mail.warn
/var/log/uucp.log
/var/log/user.log
/var/log/daemon.log
/var/log/messages
/var/log/debug
/var/log/auth.log
/var/log/mail.err
/var/log/mail.log
/var/log/kern.log
/var/log/lpr.log
/var/log/mail.info
So I have to use the -s switch to exclude mail.log and mail.info such that logrotate can take care of them. As I also have a separate config for /var/log/messages in /etc/logrotate.d/messages, I modified the call of syslogd-listfiles --weekly in /etc/cron.weekly/sysklogd to
CODE: syslogd-listfiles --weekly -s "(messages|mail.(log|info))"
Continue reading "What the hell is rotating my mail.log?"
Posted by Stephan Paukner
in GNU/Linux
at
16:06
| Comments (0)
| Trackbacks (0)
Defined tags for this entry: debian
(Page 1 of 1, totaling 1 entries)
|
AboutCalendarArchivesCategoriesShow tagged entriesandroid antenna anti-spam apache astronomy austria automobile ballooning bash bluetooth bug career cloud comic cooking crypto cw debian diy dreams education electronics fail fashion finance flickr fuerteventura fun gentoo geography german gnu-linux gnucash google google earth guitar hardware history image processing internet kernel kids language lifestyle linkroll literature ltd machine learning making mallorca mathematics matlab microsoft migration movies munich music nautilus numismatics octave pdf perl philately philosophy phone photo gear photography podcast politics postfix private programming public transport rant religion review salzburg samsung science security shtf social web software statistics storage sustainability symbian tablet time lapse transceiver tv usenet venice video virtualization wordplay work www yahoo youtube
Syndicate This BlogFollow meBookmarks
Powered by |