1

sorry about low level english

IN MY STAGING SERVER

I want logrotate every day(nginx)

so I create logrotate file in /etc/logrotate.d/

/etc/logrotate.d/nginx

/var/log/nginx/*log {
    create 0644 nginx nginx
    daily
    rotate 30
    missingok
    notifempty
    nocompress
    dateext
    dateformat -%Y%m%d
    sharedscripts
    postrotate
        if [ -f /var/run/nginx.pid ]; then
                 kill -USR1 `cat /var/run/nginx.pid`
        fi
    endscript
}

and I insert logrotate file in cron.daily

/etc/cron.daily/logrotate

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

and I check /etc/anacrontab

/etc/anacrontab

# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1       5       cron.daily              nice run-parts /etc/cron.daily
7       25      cron.weekly             nice run-parts /etc/cron.weekly
@monthly 45     cron.monthly            nice run-parts /etc/cron.monthly

and I check ls -la /var/spool/anacron/cron.daily

/var/spool/anacron/cron.daily

20180221

nginx logs will rotate like access.log, access.log-20180222

but when i command run-parts /etc/cron.daily

It doesn't working...

strangly when i insert command line /usr/sbin/logrotate -f /etc/logrotate.conf

it work very well!

I think /etc/cron.daily/logrotate not executed when run-parts /etc/cron.daily

but In my local docker I command run-parts /etc/cron.daily, It works

only staging server is not working ,,

why /etc/cron.daily/logrotate file not working when I command run-parts /etc/cron.daily??

0

problem solved

it is permission problem

chmod 700 logrotate

-rw------- logrotate -> -rwxr--r-- logrotate

it works well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.