How to Setup and Manage Log Rotation Using Logrotate in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.95/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Gabriel Cánepa

Gabriel Cánepa is a GNU/Linux sysadmin and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

5 Responses

  1. K Sinclair says:

    Hi, I am new to Linux and recently built a syslog server but the log file is not rotating. I have the entry below for the logrotate.conf file and the error I get when I try to force it to run using:

    # logrotate -vdf /etc/logrotate.conf

    Can you tell me what I need to change for the rotate to run properly.

    /var/log/Firewalls/firewall.log {
    rotate 30
    systemctl restart rsyslog

    (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

  2. fatboy92 says:

    Hi all,

    What about cases where the outdoor is never close. I had that case, it meant that the file ran full, i.e. the file system ran full, the file however showed only a small.size. A real problem when you don’t know. The file system says it’s full, but the sum of all file sizes is much smaller than the file system.

  3. Ravikumar says:

    How to rotate logs manually. If I want to rotate the log files now, what to do?

    • Gabriel A. Cánepa says:

      As explained in this very article, you can rotate the logs by using the same command as in the dry-run – just omit the -d option. Assuming you want to process the /var/log/squid/access.log file, do:
      logrotate /etc/logrotate.d/squid.conf

    • gasmyr says:

      logrotate -f myConfig_file, have a look in man page of logrotate(man logrotate)

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *