Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Find below the logrotate configuration that I'm using

/usr/local/nagios/var/nagios.log {
    rotate 7
    size 100M

And I could notice that the status file /var/lib/logrotate.status is getting updated with current date daily but the log file is not getting rotated and it's growing in GB's until the disk get filled.

What would be the problem?

share|improve this question

The problem is likely that Nagios is never killed/restarted so that it starts logging to a new log file. Here are a couple examples that show how you'd go about doing the postrotate action.

/var/log/nagios/nagios.log {
rotate 180
        /sbin/service nagios reload > /dev/null 2>/dev/null || true

Or something more direct:

/var/log/nagios/nagios.log {
        /bin/kill -HUP `cat /var/run/nagios.pid 2> /dev/null` 2> /dev/null || true

Letting Nagios do it

However in newer versions of Nagios it actually will rotate its own log files. The included logrotate configuration file even states as much.

On a Fedora 19 install of Nagios version 3.5.1-1:

$ more /etc/logrotate.d/nagios
# Important!  Nagios rotates its own logs.  Only enable this logrotate if you
# know what you are doing!

# For more information please see "log_rotate_method" in: 
# /etc/nagios/nagios.cfg

# ----- logrotate config -------------
#/var/log/nagios/*.log {
#       missingok
#       weekly
#       notifempty
#       nocompress
#       create 644 nagios nagios
share|improve this answer
Yes, seems the problem. The OP should see a lot of ascii char 000 (Nul) (shown as : ^@ with cat -v, or in vi) at the beginning of the file. Why? Nagios is writing to the current position in the file, because its file decriptor points to that position. So linux happily do that and create a sparse file with zeroes before that "current position". (To avoid that, a program logging should always seek until the end, having opened the file in append mode (or with >> if it is a script) instead of the regular write (or '>' in a script). Thus it would seek until position 0 when the fil – Olivier Dulac May 31 '14 at 6:37

Your Answer


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.