Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2766520
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2013-09-23 13:47:44

[root@hy1 logrotate.d]# pwd
/etc/logrotate.d
[root@hy1 logrotate.d]# ls nginx  php-fpm  mysql 
mysql  nginx  php-fpm
[root@hy1 logrotate.d]# cat nginx 
/data/nginx/logs/*.log {
 daily
 rotate 7
 missingok
 notifempty
 sharedscripts
 postrotate
     if [ -f /var/run/nginx.pid ]; then
         kill -USR1 `cat /var/run/nginx.pid`
     fi
 endscript
 }
[root@hy1 logrotate.d]# cat php-fpm 
/usr/local/webserver/php/var/log/*.log {
 daily
 rotate 7
 missingok
 notifempty
 sharedscripts
 postrotate
     if [ -f /var/run/nginx.pid ]; then
         kill -USR1 `cat /usr/local/webserver/php/var/run/php-fpm.pid`
     fi
 endscript
 }
[root@hy1 logrotate.d]# cat mysql 
/home/mysql_slow/mysql_slow.log {
    daily
    rotate 7
    dateext
    compress
    missingok
    #notifempty
    sharedscripts
    create 644 mysql mysql
    postrotate
        /data/mysql/bin/mysqladmin flush-logs
    endscript
}
最后一个mysql 运行需要指定用户名和密码
或者在my.cnf中加入:
  1. [mysqladmin]
  2. user = root
  3. password = *******


  1. [root@hy1 logrotate.d]# crontab -l
  2. 59 23 * * * /usr/sbin/logrotate -f /etc/logrotate.d/nginx
  3. 59 23 * * * /usr/sbin/logrotate -f /etc/logrotate.d/php-fpm
  4. 59 23 * * * /usr/sbin/logrotate -f /etc/logrotate.d/mysql


阅读(1821) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~