I have a CentOS 6.7 box that for some reason fails to rotate logs daily. I'm getting an e-mail similar to this one every day in /var/mail/root:
To: email@example.com Content-Type: text/plain; charset="ANSI_X3.4-1968" Subject: Anacron job 'cron.daily' on server.nl Message-Id: <20160309024202.4847824B4A@server.nl> Date: Wed, 9 Mar 2016 03:42:02 +0100 (CET) /etc/cron.daily/logrotate: error: error creating unique temp file: Permission denied
logrotate -vf /etc/logrotate.conf rotates logs as expected without errors or warnings. SELinux is enabled so I suspected that it might be the cause of the permission denied error, but
/var/log/audit/audit.log doesn't have entries for anything in the last few weeks.
I'm not sure how to troubleshoot what is causing logrotate to fail in the night while it working fine during the day if I'm running it manually.
Addition March 10: thanks to Iain I've been able to get log output of what (ana)cron is doing during the night, at the end of
/tmp/logrotate.out are the following lines:
@rotating pattern: /var/log/btmp monthly (1 rotations) empty log files are rotated, old logs are removed considering log /var/log/btmp log does not need rotating set default create context error: error creating unique temp file: Permission denied
This was not what I was expecting since it is not an error related to the Rails apps' logs I was trying to troubleshoot. By not focusing on the error message itself (which yielded only a couple of hits on Google in Korean and Russian) but more on that actual problem I'm having, I found logrotate cron job not rotating certain logs which is very similar to the problem I'm trying to solve (my nginx logs do rotate, it skips the Rails logs). So it might be SELinux related after all, even if it didn't show up in
audit.log. I'm trying the solution posted there.