Google

logrotate fails to rotate logs on RHEL4

We have a few RHEL4 servers, logs fail to rotate on the production machines, but not unmodified machines. We discovered that this is a known bug with using noexec on /tmp https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=156594 If you change your /tmp mount to noexec, logrotate cannot work because it tries to execute a script in /tmp to do the rotation. The hack to get it working is to add a TMPDIR in the cron job that runs logrotate (and create a directory that it can execute a script in, mkdir /root/tmp; chmod 1777 /root/tmp)
#!/bin/sh
 
export TMPDIR=/root/tmp
 
/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

One Response to “logrotate fails to rotate logs on RHEL4”

  1. logrotate Says:

    Excellent article companion.

    Logrotate is tremendously useful to be able to support of optimized form our files logs during a long period of time, since beside rotating them we can compress them automatically if we consider it opportune.

    Logrotate is an indispensable tool.

    A greeting,
    Alejandro Arco

Leave a Reply