#!/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
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)