log rotation for the CPM's /var/log/messages file

book

Article ID: 167969

calendar_today

Updated On:

Products

XOS

Issue/Introduction

The CPM's "log rotate" runs at 04:02 am every day, and messages file is rotated if it's greater than 5M in size.n/a

Cause

Provide the logic for log rotate of messages files.

Resolution

As per the default logrotate configuration in XOS, messages file larger than 5M are rotated during a daily cronjob. Smaller messages file will be rotated on a weekly basis and 4 weeks of backlogs will be kept.

Here is an example code snippet from XOS 9.6.5 for log rotate of messages file:

1) Execute log rotate on daily basis at 04:02:

[[email protected] admin]# cat /etc/cron.daily/logrotate
#!/bin/sh


chattr -a /var/log/messages
/usr/sbin/logrotate /etc/logrotate.conf
chattr +a /var/log/messages


...

2) Rotate files once a week by default:

[[email protected] admin]# head /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4


3) Rotate syslog files also if size exceeds 5M:

[[email protected] admin]# head /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
size=5M
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
/bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}

Workaround

N/A