Sometimes, you need to rotate your logs hourly instead of daily or weekly, if you have a big virtual environment many things needs to be logged. Sometimes daily logs are so huge that you need hourly log-rotation. For this one you need to customize some of the settings in your central syslog server. You can find the sample steps below to create logrotate configuration that rotates the logs hourly.
Steps:
1 - Copy /etc/cron.daily/logrotate to /etc/cron.hourly and set it as executable.
|
|
2- Create a folder logrotate.hourly.conf in /etc
# mkdir -p /etc/logrotate.hourly.conf
3- Modify the file logrotate in the /etc/cron.hourly based on your needs. See below for sample.
|
|
3- Create your logrotate script in the folder /etc/logrotate.hourly.conf
For this post, we named it as ‘example’. (We also specified it in the configuration /etc/logrotate.hourly.conf/logrotate)
|
|
- You may need to tune up rotate, size and maxage options based on your needs.