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.

In a Ubuntu 12.04 server, logrotate for Squid3 is not working. I have found the problem while noticing the partition is getting full from squid3 logs. A forced logrotate yields the following error:

~# logrotate -f /etc/logrotate.d/squid3
error: error running shared prerotate script for '/var/log/squid3/*.log

Here is the complete debug output:

~# logrotate -f /etc/logrotate.d/squid3 -d
reading config file /etc/logrotate.d/squid3
reading config info for /var/log/squid3/*.log

Handling 1 logs

rotating pattern: /var/log/squid3/*.log  forced from command line (2 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/squid3/access.log
  log needs rotating
considering log /var/log/squid3/cache.log
  log needs rotating
rotating log /var/log/squid3/access.log, log->rotateCount is 2
dateext suffix '-20140312'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/squid3/access.log.1 does not exist
renaming /var/log/squid3/access.log.2.gz to /var/log/squid3/access.log.3.gz (rotatecount 2, logstart 1, i 2),
renaming /var/log/squid3/access.log.1.gz to /var/log/squid3/access.log.2.gz (rotatecount 2, logstart 1, i 1),
renaming /var/log/squid3/access.log.0.gz to /var/log/squid3/access.log.1.gz (rotatecount 2, logstart 1, i 0),
rotating log /var/log/squid3/cache.log, log->rotateCount is 2
dateext suffix '-20140312'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/squid3/cache.log.1 does not exist
renaming /var/log/squid3/cache.log.2.gz to /var/log/squid3/cache.log.3.gz (rotatecount 2, logstart 1, i 2),
renaming /var/log/squid3/cache.log.1.gz to /var/log/squid3/cache.log.2.gz (rotatecount 2, logstart 1, i 1),
renaming /var/log/squid3/cache.log.0.gz to /var/log/squid3/cache.log.1.gz (rotatecount 2, logstart 1, i 0),
running prerotate script
running script (multiple) with arg /var/log/squid3/*.log : "
                test ! -x /usr/sbin/sarg-reports || /usr/sbin/sarg-reports
               "
renaming /var/log/squid3/access.log to /var/log/squid3/access.log.1
renaming /var/log/squid3/cache.log to /var/log/squid3/cache.log.1
running postrotate script
running script (multiple) with arg /var/log/squid3/*.log : "
                test ! -e /var/run/squid3.pid || /usr/sbin/squid3 -k rotate
"
removing old log /var/log/squid3/access.log.3.gz
error: error opening /var/log/squid3/access.log.3.gz: file or directory not found

Any idea what can be checked here? Thanks.

share|improve this question
    
Did you try manually running the prerotate scripts individually? –  ETL Mar 11 at 17:11
    
@ETL yes. I have added now the full debug output. Thanks. –  bangal Mar 12 at 10:42
    
I have found the problem with one of the prerotate scripts which was failing silently without generating any error. After fixing it logrotate is working. Thanks @ETL for the hint. understanding-logrotate-part-1 & part-2 helped a lot. –  bangal Mar 13 at 8:56
    
In this case, logrotate -vf /etc/logrotate.d/squid3 (-v for vervose, -f for force) was more helpful finding the problem. This showed the output from each prerotate script. In case with the -d (debug) option the output was rather confusing. –  bangal Mar 13 at 9:13

1 Answer 1

up vote 0 down vote accepted

As indicated by the log entries, there is an error with the prerotate scripts.

To debug this, one can remove the scripts from the configuration and add them back one by one until the troublesome one is found.

They can also be executed manually to see which one fail but in this case, the OP said they failed silently.

Using logrotate -vf /etc/logrotate.d/squid3 (-v for vervose, -f for force) is another option which in this case helps getting data on the problem.

Good documentation on logrotate can be found here:

share|improve this answer

Your Answer

 
discard

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

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