Re: can't rotate logs
DragonDon <dragondon@dragondon.net> wrote:
> I have setup logrotate and forgot to setup the cron job. Part of my
> troubleshooting was to run it manually but I get a bunch of permission
> errors http://paste.debian.net/179771/.
The relevant ones are these (which it would have been more helpful to
paste here) -
$ sudo /usr/sbin/logrotate -f /etc/logrotate.conf
error: error creating output file /var/log/exim4/mainlog.1.gz: File exists
error: error creating output file /var/log/fail2ban.log.1.gz: File exists
...
error: error creating output file /var/log/messages.1.gz: File exists
error: error creating output file /var/log/tor/log.1.gz: File exists
> I was running it manually with 'sudo /usr/sbin/logrotate -f
> /etc/logrotate.conf'
The reasons for these errors are not at all obvious until you have come
across them once before. Take the exim4 error as a worked example. The
process is (very approximately) this -
1. rename mainlog to mainlog.1
2. create a new empty mainlog
3. compress mainlog.1 (to mainlog.1.gz)
What happens here is that the compression code finds that mainlog.1.gz
already exists, so it cannot (will not) overwrite it while compressing
mainlog.1. Instead, it stops with a "File exists" error.
You can try this for yourself like this -
date > date.txt
gzip date.txt
date > data.txt
gzip date.txt
The solution in each of the error instances is to decide which of X and
X.gz you want to keep, as you can't have both.
Chris
Reply to: