[CentOS] Manually rolling logfiles over

John R Pierce pierce at hogranch.com
Fri Jan 16 23:14:36 UTC 2009

Joseph L. Casale wrote:
> How can I do this w/o restarting services or rebooting?

centos is setup using logrotate, which rotates logs according to various 
conf files (/etc/logrotate.conf has the global defaults, and 
/etc/logrotate.d/* has the app specific settings)

this is normally invoked every 24 hours from the script 

most logfiles default to weekly rotation,  with 4 logfiles kept in 
rotation, unless you change the appropriate conf files...

-some- applications (postgres 8.x comes to mind) have their own log 
rotation logic and don't use this system.

if you really want to do a -manual- rotate, you'd have do something like...

cd /dir/of/logfile
rm logfile.4
mv logfile.3 logfile.4
mv logfile.2 logfile.3
mv logfile.1 logfile.2
mv logfile logfile.1
touch logfile
service whateverservice reload

(adjusting the `mv` commands to suit however many files are in rotation)

More information about the CentOS mailing list