Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have lograotate configured on CentOS 6. It works fine when I run it manually, but with CRON it doesn't work. Cron says in its logs: "All fine, I run you command" but nothing happens. Details:

cat /etc/logrotate.d/myproject

/var/opt/myproject/log/error.log {
    size=200M
    rotate 25
    missingok
    notifempty
    copytruncate
    nocreate
    nocompress
    nodateext
}

cat /etc/cron.d/1everymin

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
* * * * * root /etc/cron.min/logrotate

cat /etc/cron.min/logrotate

#!/bin/sh

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

Every minute I see in /var/log/cron

Jan 16 21:40:01 localhost CROND[31541]: (root) CMD (/etc/cron.min/logrotate)
Jan 16 21:41:01 localhost CROND[31552]: (root) CMD (/etc/cron.min/logrotate)
Jan 16 21:42:01 localhost CROND[31561]: (root) CMD (/etc/cron.min/logrotate)
Jan 16 21:43:01 localhost CROND[31575]: (root) CMD (/etc/cron.min/logrotate)
Jan 16 21:44:01 localhost CROND[31587]: (root) CMD (/etc/cron.min/logrotate)

But log actually is not rotated: nothing happens, /logrotate.log is empty

If I execute /etc/cron.min/logrotate manually all working fine, /logrotate.log have information about log rotating

share|improve this question
    
Has the /var/opt/myproject/log/error.log gotten to the required size of 200M? –  ZaSter Jan 23 '13 at 20:10
    
Yes, of course. It's manually filled up to 500 mb. Ok, I dont know why, but when I add the same cronjob via crontab -e under the root user it works fine –  odiszapc Jan 24 '13 at 6:12

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.