ubuntu 2

logrotate

/etc/logrotate.conf

/etc/logrotate.d

 

chattr -a /var/log/message

chattr +a /var/log/message

只能新增,不能删除或修改。

 

lsattr

 

chgrp groupname filename

chown ownername filename

chmod [-R] 777 filename

 

 

 /var/log/nginx/*log { 
    daily 
    rotate 7
    missingok 
    notifempty 
    compress 
    sharedscripts 
    postrotate 
        [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid` 
    endscript 
}

http://www.xuega.com/guoyuanyuans/blog/article_77.html

 

 

2、执行logrotate
 
#/usr/sbin/logrotate -f /etc/logrotate.d/nginx
在/usr/local/nginx/logs目录中会产生
error.log
error.log.1
说明logrotate配置成功。
 
3、让logrotate每天进行一次滚动,在crontab中添加一行定时脚本。

http://www.2cto.com/os/201204/128659.html

 

 

切换到超级用户: 
sudo -sH

 

posted @ 2012-08-19 16:09  hurner  Views(212)  Comments(0Edit  收藏  举报