Logrotate: Force Log Rotation

Normally, log rotation in Linux is handled by daily cron job.

The default configuration file is /etc/logrotate.conf and service or server specific configurations are stored in /etc/logrotate.d directory.

Sometimes it needs to force rotation of some files manually.

Below you will find how to debug and force logrotate manually.

Cool Tip: Everything you should know about crontab: the format of crontab, cron job syntax and examples of how to run cron job every minute, 5 minutes, hour, day (daily), etc. Read more →

Force Log Rotation

Check what will happen when logrotate is forced (no changes will be made):

$ logrotate -vdf CONFIG_FILE

Manually force logrotate:

$ logrotate -vf CONFIG_FILE

The options passed to the logrotate command:

Option Description
-d, --debug Dry run logrotate.
-f, --force Force logrotate.
-v, --verbose Shows more information.

Info: With the -f, --force option the logrotate will force the rotation of files even if they do not meet the specified criteria such as minsize, age, etc.

Was it useful? Share this post with the world!

2 Replies to “Logrotate: Force Log Rotation”

  1. Thanks mate.

  2. Hello.
    Can you send email with the directive mail from logrotate?
    I use debian with logrotate and exim but I dont have any mail for my admin.

Leave a Reply