The logrotate package is very useful and can prevent being woken up in the middle of the night with a disk filling up due to log files. It will automatically rotate, compress, remove, mail log files and you can further extend that by running scripts before or after the rotation. You can have it rotate daily, weekly, monthly or based on file size if a file grows to large.
logrotate is part of the CentOS base and the main configuration file is /etc/logrotate.conf which contains global variables that are used if not defined specifically for a certain log. This conf file also includes the confs located in /etc/logrotate.d where you would create an entry to rotate any additional logs.
In this example, we have a logfile /var/log/foomanchoo.log, we want to rotate it daily, compress it, retain a month’s worth of logs.
We will create a conf entry in /etc/logrotate.d/ and call it foomanchoo.
Paste this as the whole file