Nginx 访问日志轮询切割
Nginx 访问日志轮询切割脚本
#!/bin/sh
Dateformat=`date +%Y%m%d`
Basedir="/application/nginx"
Nginxlogdir="$Basedir/logs"
Logname="access_www"
[ -d $Nginxlogdir ] && cd $Nginxlogdir||exit 1
[ -f ${Logname}.log ]||exit 1
/bin/mv ${Logname}.log ${Dateformat}_${Logname}.log
/bin/mv access_bbs.log ${Dateformat}_access_bbs.log
/bin/mv access_blog.log ${Dateformat}_access_blog.log
$Basedir/sbin/nginx -s reload
配置www.conf
[root@lnmp02 scripts]# vim /application/nginx/conf/extra/www.conf
server {
listen 80;
server_name www.judong.org judong.org;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/access_www.log main;
}
配置bbs.conf
[root@lnmp02 scripts]# vim /application/nginx/conf/extra/bbs.conf
server {
listen 80;
server_name bbs.judong.org;
location / {
root html/bbs;
index index.html index.htm;
}
access_log logs/access_bbs.log main; ##添加访问日志
}
~
配置blog.conf
[root@lnmp02 scripts]# vim /application/nginx/conf/extra/blog.conf
server {
listen 80;
server_name blog.judong.org;
location / {
root html/blog;
index index.html index.htm;
}
access_log logs/access_blog.log main;
}
测试
[root@lnmp02 scripts]# ll /application/nginx/logs/
total 40
-rw-r--r--. 1 root root 756 Mar 3 22:07 20160315_access_www.log
-rw-r--r--. 1 root root 0 Mar 15 09:27 20160316_access_www.log
-rw-r--r--. 1 root root 0 Mar 17 2016 20160317_access_bbs.log
-rw-r--r--. 1 root root 0 Mar 17 2016 20160317_access_blog.log
-rw-r--r--. 1 root root 0 Mar 17 2016 20160317_access_www.log
-rw-r--r--. 1 root root 0 Mar 17 2016 access_bbs.log
-rw-r--r--. 1 root root 0 Mar 17 2016 access_blog.log
-rw-r--r--. 1 root root 22177 Mar 3 22:06 access.log
-rw-r--r--. 1 root root 0 Mar 17 2016 access_www.log
-rw-r--r--. 1 root root 2088 Mar 17 2016 error.log
-rw-r--r--. 1 root root 5 Mar 3 19:31 nginx.pid
配置定时任务使得每天0点整执行脚本
[root@lnmp02 scripts]# crontab -l
######cut nginx access_www.log########
00 00 * * * /bin/sh /server/scripts/cut_nginx_log.sh >/dev/null 2>&1
Nginx 访问日志轮询切割的更多相关文章
- Nginx的继续深入(日志轮询切割,重写,负载均衡等)
Nginx的访问日志轮询切割 通常什么情况Nginx会把所有的访问日志生成到一个制定的访问日志文件access.log里面,但时间一长,日志个头很大不利于日志的分析和处理. 有必要对Nginx日志进行 ...
- nginx日志配置,以及日志轮询
一.为nginx配置错误日志 Nginx错误日志是调试nginx的重要手段,属于核心功能模块的参数(ngx_core_module)该参数名字为err_log,是放在Main区块中全局配置 err_l ...
- 按日期切割nginx访问日志--及性能优化
先谈下我们需求,一个比较大的nginx访问日志,根据访问日期切割日志,保存在/tmp目录下. 测试机器为腾讯云机子,单核1G内存.测试日志大小80M. 不使用多线程版: #!/usr/bin/env ...
- Nginx访问日志、 Nginx日志切割、静态文件不记录日志和过期时间
1.Nginx访问日志 配制访问日志:默认定义格式: log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_loc ...
- Nginx访问日志、日志切割、静态文件不记录日志和过期时间
6月8日任务 12.10 Nginx访问日志12.11 Nginx日志切割12.12 静态文件不记录日志和过期时间 12.10 Nginx访问日志 除了在主配置文件nginx.conf里定义日志格式外 ...
- Linux centosVMware Nginx访问日志、Nginx日志切割、静态文件不记录日志和过期时间
一.Nginx访问日志 vim /usr/local/nginx/conf/nginx.conf //搜索log_format 日至格式 改为davery格式 $remote_addr 客户端IP ...
- Nginx访问日志.Nginx日志切割
11月27日任务 12.10 Nginx访问日志12.11 Nginx日志切割12.12 静态文件不记录日志和过期时间 1.Nginx访问日志 示例一: 日志格式 vim /usr/local/ngi ...
- nginx访问日志(access_log)
一.nginx访问日志介绍 nginx软件会把每个用户访问网站的日志信息记录到指定的日志文件里,供网站提供者分析用户的浏览行为等,此功能由ngx_http_log_module模块负责,对应的官方地址 ...
- Apache日志轮询Cronolog安装及简单用法
安装日志轮询工具cronolog: [root@bqh- tools]# tar xf cronolog-.tar.gz [root@bqh- tools]# cd cronolog- [root@b ...
随机推荐
- MySQL基础之视图
关于视图 视图是虚表,其中并不存在数据,只是多个表的组成 使用视图的优势 视图可以代替复杂的查询SQL语句,可以事先将不同表的多个数据组织起来 提高权限控制管理,能够将权限限制为行级管理,更具有安全性 ...
- Spark 学习总结
摘要: 1.spark_core 2.spark_sql 3.spark_ml 内容: 1.spark_core 原理篇: Spark RDD 核心总结 RangePartitioner 实现简记 S ...
- CSS实现水平|垂直居中漫谈
利用CSS进行元素的水平居中,比较简单,手到擒来:行级元素设置其父元素的text-align center,块级元素设置其本身的left 和 right margins为auto即可.而撸起垂直居中, ...
- 【.NET深呼吸】元组数据(Tuple)
各位观众,大家好,欢迎收看由火星电视台直播的<老周吹牛>节目,注意:本节目没有任何技术含量,如果您没有兴趣,请砸掉电视机. 今天说一下System命名空间下的一个数据类型——Tuple,翻 ...
- Compile FreeCAD on Windows
Compile FreeCAD on Windows eryar@163.com 1.Introduction FreeCAD是一个参数化的三维造型软件,主要用于任意大小的实际模型的设计.参数化的建模 ...
- 前端学HTTP之网络基础
× 目录 [1]网络 [2]OSI [3]TCP/IP 前面的话 HTTP协议对于前端工程师是非常重要的.我们在浏览网站时,访问的每一个WEB页面都需要使用HTTP协议实现.如果不了解HTTP协议,就 ...
- Java正则速成秘籍(一)之招式篇
导读 正则表达式是什么?有什么用? 正则表达式(Regular Expression)是一种文本规则,可以用来校验.查找.替换与规则匹配的文本. 又爱又恨的正则 正则表达式是一个强大的文本匹配工具,但 ...
- 微信小程序demo2
接着上篇 微信小程序-阅读小程序demo写:http://www.cnblogs.com/muyixiaoguang/p/5917986.html 首页banner动画实现 京东新闻上下动画实现 ...
- JWT实现token-based会话管理
上文<3种web会话管理的方式>介绍了3种会话管理的方式,其中token-based的方式有必要从实现层面了解一下.本文主要介绍这方面的内容.上文提到token-based的实现目前有一个 ...
- 2017Windows下安装pip
-------------------------------------------- 下载地址: https://pypi.python.org/pypi/pip#downloads 下载颜色那 ...