How to make log-rotate change take effect

  • I followed this link to change log-rotate configuration for RHEL 6

    After I made the change to config file, what should I do to let this take effect?

  • Kiwy

    Kiwy Correct answer

    7 years ago

    logrotate uses crontab to work. It's scheduled work, not a daemon, so no need to reload its configuration.
    When the crontab executes logrotate, it will use your new config file automatically.
    If you need to test your config you can also execute logrotate on your own with the command:

    logrotate /etc/logrotate.d/your-logrotate-config
    

    Or as mentioned in comments, identify the logrotate line in the output of the command crontab -l and execute the command line refer to slm's answer to have a precise cron.daily explanation

    Just to add to your answer, the cron entry for `logrotate` is scheduled to run once a day.

    @Ketan, so, how can i make it affect right away? thanks

    Not sure. One possibility is to find the corresponding entry from crontab via `crontab -l` and execute it.

    If you want it to take effect immediately run the cron afterwords.

    You can also just run `logrotate` directly as mentioned in the answer.

    `/you/config/file` can be misunderstood as a path to a particular config for some application's logs, such as `/etc/logrotate.d/foo`. This is usually wrong; only the main config should be used because others can inherit some values from the main one.

    `logrotate` has a `-d` option for testing (or "debugging"), I'd recommend running it at least once with that.

    A very common frustration is the new, required su directive `su root syslog`. Which brings logrotate to a halt when not added in. To top off people's frustration, when they add the directive, and then run (force) logrotate, it continues to spit out "`error: skipping "/var/log/syslog" because parent directory has insecure permissions (It's world writable or writable by group which is not "root" ...`" for 20 hrs after the config change, as if the the settings/process are cached!? If you are stuck there, chgrp on /var/log to root, run logrotate, chgrp back to syslog. It will clear up by next run

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM