50

I have logrotate running in an EC2 AWS machine rotating Apache logs. Once packed, Apache logs are saved into AWS S3 via s3fs. The problem is that I recently noticed that I didn't have logs rotated. In S3 I have old logs from day 48->60 but the 1->47 doesn't appear.

My question is: Where does logrotate save its own log? It's possible that I have some kind of problem with s3fs, but I need to know before I do anything. I tried to find somewhere the logs but I couldn't find it out.

Any idea?

womble
  • 96,255
  • 29
  • 175
  • 230
enedebe
  • 1,066
  • 3
  • 11
  • 18

6 Answers6

37

logrotate does not log anything by default. normally it should be in your cron somewhere, for instance:

$ grep -r -- 'logrotate.conf' /etc/cron*
/etc/cron.daily/logrotate:/usr/sbin/logrotate /etc/logrotate.conf

You can either run that manually to see what is wrong, or redirect the logrotate output to a file in the above cron to see what happened next day.

Likely somewhere the config is incorrect and caused the logrotate run to break.

StackzOfZtuff
  • 1,842
  • 13
  • 21
johnshen64
  • 5,865
  • 24
  • 17
  • 3
    +1 on running logrotate manually to see what's wrong – cjc Apr 19 '12 at 12:20
  • thanks for the answer, but what I really want to know what has happened in my system to get this kind result. Thank's! – enedebe Apr 19 '12 at 21:26
  • does manually run logrotate give any errors? if there are errors, you need to fix them in the conf file or /etc/logrotate.d/apache (or apache2). – johnshen64 Apr 19 '12 at 21:50
  • 7
    You can use the `-d` debug flag and the `-f` force flag to see exactly what logrotate is attempting to do. `-d` disables action but the printed messages will still claim they're changing things. – David Lord Jul 23 '15 at 03:44
  • 1
    When running `/usr/sbin/logrotate /etc/logrotate.conf`, I'd add `-v` to see the detailed log. – Dennis Golomazov Nov 18 '19 at 13:25
  • Combining everyone's suggestions, it sounds like manually running `logrotate -dfv` is most helpful. My command already had `-s ` on it, so I ended up using `logrotate -dsfv ` for debugging. – rinogo Sep 30 '20 at 19:27
23

The only thing that logrotate records normally is in cat /var/lib/logrotate/status.

This is taken from https://serverfault.com/a/518134/266525

dragon788
  • 806
  • 8
  • 10
  • 1
    It turns out there are differences in the actual path depending on the distribution and version used. Check the linked serverfault answer and it's comments for details. – Attila Csipak Oct 01 '20 at 12:46
  • 4
    `/var/lib/logrotate/logrotate.status` on my CentOS 7 system. – rinogo Oct 02 '20 at 18:25
9

Another good place to look is /var/log/messages on CentOS for errors such as this from the cron.daily /etc/cron.daily/logrotate

logrotate: ALERT exited abnormally with [1]

You can also run in debug mode manually and check for errors:

/usr/sbin/logrotate -d /etc/logrotate.conf

Source: https://access.redhat.com/solutions/32831

Tony-Caffe
  • 268
  • 2
  • 8
4

If you're running logrotate from cron and not redirecting the output, the output, if there is any, will go to email for whichever ID is running the cron job. I redirect my output to a log file.

For example:

25 3 * * 7 /usr/sbin/logrotate -s /home/user/conf/mwarelogrotate.state 
/home/user/conf/mwarelogrotate.conf >> /home/user/logs/logrotate.log 2>&1
StackzOfZtuff
  • 1,842
  • 13
  • 21
2

When logrotate doesn't rotate logs or enters failed state, it's a good idea to run logorate manually in debug mode to see what errors it lists, like this:

/usr/sbin/logrotate -d /etc/logrotate.d/*

This command tests rotating the logs for all the services that have files located in /etc/logrotate.d. If it lists errors (such as errors caused by duplicate log entries), you'll know why logrotate has problems.

Ludvik
  • 21
  • 5
1

Check /etc/logrotate.conf for global config settings that may be affecting tasks configured through /etc/logrotate.d/

cdmo
  • 113
  • 5