0

I am trying to understand the output of my logrotate script execution:

error: error running shared postrotate script for '/var/log/nginx/*.log '
logrotate_script: 2: logrotate_script: service: not found
error: error running non-shared postrotate script for /var/log/syslog of '/var/log/syslog '
logrotate_script: 2: logrotate_script: service: not found
error: error running shared postrotate script for '/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages '

As far as I understand, logrotate encounters an error while running the postrotate scripts for nginx and syslog, respectively service nginx rotate >/dev/null and service rsyslog rotate > /dev/null.

Logrotate script (/etc/logrotate.d/nginx)

/var/log/nginx/*.log {
    daily
    missingok
    rotate 365
    compress
    delaycompress
    notifempty
    create 0640 www-data www-data
    olddir /var/log/archives/nginx
    sharedscripts
    prerotate
            if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                    run-parts /etc/logrotate.d/httpd-prerotate; \
            fi \
    endscript
    postrotate
            invoke-rc.d nginx rotate >/dev/null 2>&1
    endscript
}

Logrotate is run through cron as root, and running the postrotate scripts manually goes without problems:

Crontab entry (root)

00 00 * * * /usr/sbin/logrotate -s /var/lib/logrotate/status /etc/logrotate.conf

Manual postrotate script execution

$ invoke-rc.d nginx rotate >/dev/null 2>&1 && echo $? 
0


What could explain this service:not found message ?

1
  • You are missing the path?! Try /usr/sbin/service – JohannesM Jan 19 '16 at 17:26
0

Can you write the context of /etc/logrotate.conf or file with the ngix log rotation rules?

In rh/centos 'service' is in /sbin/service but in debian/ubuntu is in '/usr/sbin/service. Do you have absolute path in pre or post rotate?

1
  • 1
    I added the log rotation rules, which are the package's default. As you can see, there is no absolute path. – PLNech May 2 '16 at 14:06

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.