How can I do this w/o restarting services or rebooting?
Thanks! jlc
2009/1/16 Joseph L. Casale JCasale@activenetwerx.com:
How can I do this w/o restarting services or rebooting?
If I understood well what you are looking for, to manually rotate your logs, you could launch logrotate as follows:
logrotate -f /etc/logrotate.d/<service>
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 /etc/cron.daily/logrotate
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)
Joseph L. Casale wrote on Fri, 16 Jan 2009 15:11:35 -0700:
How can I do this w/o restarting services or rebooting?
Neither restarting services nor rebooting rotates logs. man logrotate shows you how to do that manually what logrotate does during the night. You can also do a dry-run.
Kai
Joseph L. Casale wrote:
How can I do this w/o restarting services or rebooting?
copy/truncate.
copy log file to a new file and truncate the original (cat /dev/null >filename)
Or setup a logrotate config with the copytruncate option.
There is a chance I believe to drop some log events between the copy and the truncate depending on how active the log is.
Or use a log service such as syslog.
nate