Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a daily cronjob set up on CentOS 6 OS which should look after the log rotation job. The file is /etc/cron.daily/logrotate and it's contents are

#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf >/dev/null 2>&1
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

I expected that logs will be rotated as being activated by this daily cronjob but it isn't. I see no evidence that the daily cronjob is run from the log file /var/log/cron. However, the hourly jobs are run as shown by the log file.

I have added a line on /etc/crontab file

# run-parts
02 4 * * * root run-parts /etc/cron.daily 

but that made no change.

I have no idea why this log rotation isn't working. I would be pleased if someone can shed some light.

share|improve this question
    
Is /etc/cron.daily/logrotate executable? ls -l /etc/cron.daily/logrotate. –  Spack Apr 23 at 9:27
    
yes, it is. -rwxr-xr-x 1 root root 196 Jun 22 2012 /etc/cron.daily/logrotate –  mezi Apr 23 at 9:47
3  
Make your script verbose so you will see if it's running fine. For example, you can remove >/dev/null 2>&1 to have logrotate output. –  Spack Apr 23 at 10:04
    
I made the change as you suggested and found some errors. I have fixed the error and now it's no longer showing any error. I will check later whether daily crons are running. –  mezi Apr 23 at 10:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.