Linux – Logrotation – postrotate firing too soon

linuxlogrotatenginx

I have a configuration file that looks like:

/var/log/nginx/*.log {
        daily
        missingok
        rotate 90
        dateext
        compress
        notifempty
        create 644 root adm
        sharedscripts
        postrotate
                [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
                /usr/local/bin/synclogs.sh
        endscript }

synclogs.sh is supposed to run when all the log files have been rotated and compressed. The script does kick off successfully, but when it starts running, the program doesn't find any of the .gz files that logrotate was supposed to make. I ran the script manually a few minutes later, it kicks off fine.

According to docs I found, postrotate isn't supposed to kick off until compression has finished. Is that not the case? Is this a bug in the logrotate that ships in Debian Squeeze or did I just miss something very simple?

Best Answer

Have you tried this:

/var/log/nginx/*.log {
        daily
        missingok
        rotate 90
        dateext
        compress
        **delaycompress**
        notifempty
        create 644 root adm
        sharedscripts
        postrotate
                [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
                /usr/local/bin/synclogs.sh
        endscript }

Take a look at the delaycompress option, of course without "*" HTH