-
Notifications
You must be signed in to change notification settings - Fork 582
logrotate
Ulrich Habel edited this page Oct 17, 2012
·
4 revisions
Log production.log
increase little by little after you application is deployed in production environment.
If you want to maintain production log on CentOS
, Debian
, Ubuntu
and Fedora
, it is easy to use logrotate
.
You create logrotate
config file in your application directory(in this example, webapp)
cd ~/webapp
mkdir logrotate
cd logrotate
vi logrotate.conf
The following setting is one example. Current log is copied to other file once per week. Logs before 12 weeks are deleted.
/home/ken/webapp/log/production.log {
weekly
copytruncate
rotate 12
missingok
}
Let's register the command which execute rotation to crontab
.
crontab -e
You write the following setting.
0 0 * * * /usr/sbin/logrotate -s $HOME/webapp/logrotate/logrotate.status $HOME/webapp/logrotate/logrotate.conf