Logrotate in Linux

Will see how to configure/ use logrotate in Linux

to compress, move, delete or mail log files at the periodic time. By doing this will keep away the filesystem from the filesystem full issue.

Setting up and Manage logrotate in Linux:

In Linux/ Unix, environment /var/log is most important directory and it keeps all the activities as a log.

System administrators will use the logs to analyze any issue’s.

/var/log keeps lots of log files and here is the list.

[root@localhost ~]# ls /var/log
anaconda boot.log cron dmesg.old lastlog messages rhsm spooler tuned wtmp
audit btmp dmesg firewalld maillog ppp secure tallylog vmware-vmsvc.log

Installing logrotate:

Here I am going to use the yum package manager to install the logrotate.

[root@localhost ~]# yum install logrotate
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package logrotate-3.8.6-12.el7.x86_64 already installed and latest version
Nothing to do

look likes the package is already installed on my machine.

/etc/logrotate.conf is an important configuration file which contains all the configuration of log rotation and “include /etc/logrotate.d ” this line should be uncommented.

We have plenty of option in logrotate and below is that.

Will create /etc/logrotate.d/apache2.conf file and insert below content.

/var/log/apache/* {
weekly
rotate 5
size 25M
compress
delaycompress
}

Daily, Weekly, Monthly:  Based on this input the tool will rotate the logs.

rotate 5: This will keep the only 5 files and the old files will be removed.

size 25: log file minimum size for log rotation.

Compress & Delaycompress:  These are used to say that all are already rotated logs.

Now will do s test using the below command

[root@localhost ~]# logrotate -d /etc/logrotate.d/apache2.conf

 

 

Reference: Tecmint

9 thoughts on “Logrotate in Linux”

  1. I think this is one of the most important info for me. And i am glad reading your article. But should remark on some general things, The site style is wonderful, the articles is really great : D. Good job, cheers

  2. This is very interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your wonderful post. Also, I’ve shared your web site in my social networks!

  3. Yet another thing is that when searching for a good on-line electronics shop, look for web stores that are consistently updated, keeping up-to-date with the most up-to-date products, the very best deals, along with helpful information on products and services. This will make certain you are getting through a shop that stays ahead of the competition and provides you what you need to make knowledgeable, well-informed electronics expenditures. Thanks for the vital tips I’ve learned through the blog.

  4. Hey there! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to get my
    blog to rank for some targeted keywords but I’m not seeing very
    good results. If you know of any please share.
    Thank you!

Leave a Reply to ssabuthagir Cancel reply

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