centos 创建 logrotate 进行日志分割
这里就不赘述logrotate了,具体是什么,有什么作用,自行百度。
我们先说下,如何进行nginx的日志切割:
比如:日志目录为:/usr/local/nginx/logs/access.log
按照如下进行操作:(具体每个指令是什么意思,请自行百度,这里不赘述)
/usr/local/nginx/logs/access.log {
su root root
weekly
rotate
compress
dateext
sharedscripts
postrotate
[ -f /usr/local/nginx/logs/nginx.pid ] && kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
endscript
}
我们再进行Mysql的日志切割:
Mysql日志切割
比如:日志目录为:/usr/local/mysql/var/localhost-slow.log
按照如下进行操作:
/usr/local/mysql/var/localhost-slow.log {
# create mysql mysql
notifempty
daily
rotate
missingok
compress
dateext
postrotate
# just if mysqld is really running
if test -x /usr/local/mysql/bin/mysqladmin && \
/usr/local/mysql/bin/mysqladmin ping &>/dev/null
then
/usr/local/mysql/bin/mysqladmin flush-logs
fi
endscript
}
使用方法: /usr/local/logrotate -f nginx_access 或者 logrotate -f nginx_access
/usr/local/logrotate -f mysql_slow 或者 logrotate -f mysql_slow
参数: -f 可以加可以不加,加上-f是强制的意思。
以上为切割nginx与mysql日志方法,可自己修改参数。
centos 创建 logrotate 进行日志分割的更多相关文章
- 如何在Centos 7上用Logrotate管理日志文件
何为Logrotate? Logrotate是一个实用的日志管理工具,旨在简化对系统上生成大量的日志文件进行管理. Logrotate允许自动旋转压缩,删除和邮寄日志文件,从而节省宝贵的磁盘空间. L ...
- logrotate 进行nginx日志分割
http://www.williamsang.com/archives/1254.html 日志分割常用方法: 自己写脚本分割 使用linux自带的logrotate 前者灵活,可以应对各种需求,自定 ...
- Nginx-Tomcat 等运维常用服务的日志分割-logrotate
目录 一 .Nginx-Tomcat 等常用服务日志分析 Nginx 日志 Tomcat日志 MongoDB 日志 Redis 日志 二 .日志切割服务 logrotate 三.日志切割示例 Ngin ...
- 利用logrotate工具对catalina.out进行日志分割实战
logrotate是linux自带的日志分割工具,如果没有可以用yum安装 yum -y install logrotate 要配置日志分割定时任务,需要在/etc/logrotate.d/下创建一个 ...
- logrotate实现Mysql慢日志分割
MySQL慢日志? MySQL的慢查询日志是MySQL提供的一种日志记录,它用来记录在MySQL中响应时间超过阀值的语句,具体指运行时间超过long_query_time值的SQL,则会被记录到慢查询 ...
- 使用logrotate做nginx日志分割
版权申明:转载请注明出处. 文章来源:http://bigdataer.net/?p=266 背景 nginx是一款非常优秀的网络代理工具,但是其日志管理有点缺憾:nginx的access_log会无 ...
- 在Linux下使用logrotate管理日志(转)
原文地址:http://www.tuicool.com/articles/ieAnMjN logrotate是日志循环管理工具,可以分割日志文件,删除旧的日志文件,创建新的日志文件,循环管理日志从而节 ...
- logrotate nginx日志切割
1.安装 centos: yum -y install logrotate ubuntu: apt-get install -y logrotate 2. 配置文件 /etc/logrotate.co ...
- nginx 直接在配置文章中设置日志分割
直接在nginx配置文件中,配置日志循环,而不需使用logrotate或配置cron任务.需要使用到$time_iso8601 内嵌变量来获取时间.$time_iso8601格式如下:2015-08- ...
随机推荐
- Contiki Ctimer模块
Ctimer 提供和Etimer类似的功能,只是Ctimer是在一段时间后调用回调函数,没有和特定进程相关联. 而Etimer是在一段时间后发送PROCESS_EVENT_TIMER事件给特定的进程. ...
- BZOJ 1529 [POI2005]ska Piggy banks:并查集
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1529 题意: Byteazar有N个小猪存钱罐. 每个存钱罐只能用钥匙打开或者砸开. By ...
- JavaScript--Object类
Object类是所有JavaScript类的基类,提供了一种创建自定义对象的简单方式,不需要程序员再定义构造函数. 主要属性: constructor-对象的构造函数 prototype-获得类的pr ...
- Servlet传递数据方式
Servlet传递数据方式 基本概述 Servlet传递数据的方式有很多,这里提供五种方式: 1.静态变量 2.HttpServletResponse的sendRedirect()方法 3.HttpS ...
- 使用chrome的F12开发人员工具进行网页前端性能测试
用chrome访问被测网站,定位到你要测试的动作所在页面或被测页面的前一页.按F12调出开发人员工具,其它的功能我就不介绍了,直接切换到性能选项卡Profiles. 点击start,生成ProFile ...
- codeforces 558B B. Amr and The Large Array(水题)
题目链接: B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes in ...
- [Poi2011] Meteors(从不知所措到整体二分)
Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby galaxy. The plan ...
- ubuntu强制卸载软件
以卸载cups为例子 一:列出软件列表,找到需要卸载的软件的名字命令:dpkg --list
- 【Lintcode】033.N-Queens II
题目: Follow up for N-Queens problem. Now, instead outputting board configurations, return the total n ...
- 【LeetCode】016 3Sum Closest
题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given ...