February 22, 2016

How to rotate logs manually in Linux?

In Linux every activity is monitored and logged in to their respective logs in /var/log folder. The depth of log information is dependent on the log configuration we did it in /etc/logrotate.d and we have to rotate them all the time to control how much space they use. When ever we install packages, the package copies its log configuration file to /etc/logrotate.d folder so that that specific application log files can be rotated. 

Normally in any Linux/Unix machine logs are rotated daily(/etc/cron.daily/) or weekly(/etc/cron.weekly) or monthly(/etc/cron.monthly) depending where we kept our logrotate script. My logrotate script is located in /etc/cron.daily which indicate my logs are rotated daily. One more facter logrotate depends when rotatting logs is log "status" file which is located at /var/lib/logrotate/status which stores when we rotated logs last time.

Let us see how we can rotate logs manually instead of waiting for hours.

Example1: In order to check what happens when we rotate log files manually before actually executing them can be done in debug mode(-d).

Read Full Post: http://www.linuxnix.com/how-to-rotate-logs-manually-in-linux/

Click Here!