The "logrotate" function does not work resulting in very large messages file

book

Article ID: 168042

calendar_today

Updated On:

Products

XOS

Issue/Introduction

The "logrotate" function does not work resulting in very large messages fileUnder normal circumstances, a daily cron job will execute on the CPM and rotate the /var/log/messages file if it exceeds a 5Mb size threshold. However, in some cases, large messages files have been witnessed on the XOS platform.

Cause

The logrotate function called in the cron job (/etc/cron.daily/logrotate) is not able to rename the existing
/var/log/messages file - resulting in a messages file that continues to grow.

The culprit is the existence of an attribute flag set on the messages file. With this attribute set, the messages file cannot be rotated or moved.

This flag should not be set on an XOS system by default. If it is, the logrotate function does not work properly.

Resolution

To check if the attribute flag is set on the messages, exit to the Linux shell and type:

#lsattr /var/log/messages


If the flag "a" is set, the output will be as follows:

----a--------- /var/log/messages

With this a flag set on an XOS system the log never rotates. It can be appended to, but the file cannot be moved.

To clear this situation, do the following:

#chattr -a /var/log/messages

Checking the attribute on the file should then give this output:

#lsattr /var/log/messages

-------------- /var/log/messages

You should then be able to execute the /etc/cron.daily/logrotate script successfully.

Workaround

N/A