Logrotate: Forced Rotation of Logs

Typically, log rotation in Linux occurs daily on the cron. The default configuration file is /etc/logrotate.conf, and the individual log rotation rules for the services are stored in the directory /etc/logrotate.d.

Sometimes it becomes necessary to manually rotate certain files. For example, if you have high traffic server, you need to rotate logs before its default said frequency to avoid bulky files.

In this article, you will learn how to debug and force logrotate manual start.

Tip: All you need to know about crontab: setting up cron in Ubuntu and CentOS, examples crontabin Linux, running cron jobs (scripts, commands) every minute, every hour, every day, etc. Read More →

Forced Rotation of Logs

First of all, check what happens when you force it logrotate(without changing the file system):

Forced start logrotate:

Options passed to the command logrotate:

Option Description
-d, --debug Run logrotatein debug mode (trial run).
-f, --force Force to start logrotate.
-v, --verbose Show more information.

Info: Using the option -f, --force,  logrotatewill force the files to rotate, even if they do not fall under certain criteria, like minsizeage etc.

READ  How to Disable Iptables Firewall in CentOS

Authored By Imran Yousaf

I am Imran Yousaf, a computer geek, founder of the site Smashinglab.com. I am a die hard fond of open-source software and Linux operating system. In addition to Linux, I am interested in everything related to information technology and modern science.

Leave a Reply

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