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 访问日志轮询切割的更多相关文章

  1. Nginx的继续深入(日志轮询切割,重写,负载均衡等)

    Nginx的访问日志轮询切割 通常什么情况Nginx会把所有的访问日志生成到一个制定的访问日志文件access.log里面,但时间一长,日志个头很大不利于日志的分析和处理. 有必要对Nginx日志进行 ...

  2. nginx日志配置,以及日志轮询

    一.为nginx配置错误日志 Nginx错误日志是调试nginx的重要手段,属于核心功能模块的参数(ngx_core_module)该参数名字为err_log,是放在Main区块中全局配置 err_l ...

  3. 按日期切割nginx访问日志--及性能优化

    先谈下我们需求,一个比较大的nginx访问日志,根据访问日期切割日志,保存在/tmp目录下. 测试机器为腾讯云机子,单核1G内存.测试日志大小80M. 不使用多线程版: #!/usr/bin/env ...

  4. Nginx访问日志、 Nginx日志切割、静态文件不记录日志和过期时间

    1.Nginx访问日志 配制访问日志:默认定义格式: log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_loc ...

  5. Nginx访问日志、日志切割、静态文件不记录日志和过期时间

    6月8日任务 12.10 Nginx访问日志12.11 Nginx日志切割12.12 静态文件不记录日志和过期时间 12.10 Nginx访问日志 除了在主配置文件nginx.conf里定义日志格式外 ...

  6. Linux centosVMware Nginx访问日志、Nginx日志切割、静态文件不记录日志和过期时间

    一.Nginx访问日志 vim /usr/local/nginx/conf/nginx.conf //搜索log_format  日至格式 改为davery格式 $remote_addr  客户端IP ...

  7. Nginx访问日志.Nginx日志切割

    11月27日任务 12.10 Nginx访问日志12.11 Nginx日志切割12.12 静态文件不记录日志和过期时间 1.Nginx访问日志 示例一: 日志格式 vim /usr/local/ngi ...

  8. nginx访问日志(access_log)

    一.nginx访问日志介绍 nginx软件会把每个用户访问网站的日志信息记录到指定的日志文件里,供网站提供者分析用户的浏览行为等,此功能由ngx_http_log_module模块负责,对应的官方地址 ...

  9. Apache日志轮询Cronolog安装及简单用法

    安装日志轮询工具cronolog: [root@bqh- tools]# tar xf cronolog-.tar.gz [root@bqh- tools]# cd cronolog- [root@b ...

随机推荐

  1. atitit.软件与sql设计模式原理与本质 大总结attialx总结v6 qc26.docx

    atitit.软件与sql设计模式原理与本质 大总结attialx总结v6 qc26.docx 1.1. 版本历史2 2. 设计模式是什么2 2.1. 模式就是在一种场合下对某个问题的一个解决方案.& ...

  2. Atitit ABI FFI 的区别与联系 attilax总结

    Atitit ABI FFI 的区别与联系 attilax总结 FFI stands for Foreign Function Interface. A foreign function interf ...

  3. Jquery初学

    Jquery相当于JS的升级版它俩语法是一样的,把JS的很多功能封装了起来,用的也是JS语言写的,也支持JS的语法,可以混着使用,用起来方便简单 用Jquery的时候要引用一个Jquery包 带min ...

  4. WCF学习之旅—WCF服务部署到IIS7.5(九)

    上接   WCF学习之旅—WCF寄宿前的准备(八) 四.WCF服务部署到IIS7.5 我们把WCF寄宿在IIS之上,在IIS中宿主一个服务的主要优点是在发生客户端请求时宿主进程会被自动启动,并且你可以 ...

  5. JS / Egret 单笔手写识别、手势识别

    UnistrokeRecognizer 单笔手写识别.手势识别 UnistrokeRecognizer : https://github.com/RichLiu1023/UnistrokeRecogn ...

  6. 完整记录一则Oracle 11.2.0.4单实例打PSU补丁的过程

    本文记录了打PSU的全过程,意在体会数据库打PSU补丁的整个过程. 1.OPatch替换为最新版本2.数据库软件应用19121551补丁程序3.数据库应用补丁4.验证PSU补丁是否应用成功 1.OPa ...

  7. 「译」JUnit 5 系列:扩展模型(Extension Model)

    原文地址:http://blog.codefx.org/design/architecture/junit-5-extension-model/ 原文日期:11, Apr, 2016 译文首发:Lin ...

  8. Lua 安全调用 metatable 的简单应用

    事情的经过 我们的项目中存在好几个战斗界面,不过界面中的内容略有不同.跟同事出去吃饭的时候,他问我.我们现在的战斗界面.有很多是重复的,但是也有偶尔几个地方不太一样.我在战斗过程中驱动这些界面的时候. ...

  9. iis6.0与asp.net的运行原理

    这几天上网翻阅了不少前辈们的关于iis和asp.net运行原理的博客,学的有点零零散散,花了好长时间做了一个小结(虽然文字不多,但也花了不少时间呢),鄙人不才,难免有理解不道的地方,还望前辈们不吝赐教 ...

  10. 关于Agile Scrum的笔记

    Roles: Scrum Master -- advisor but leader, 替Team消除障碍 Product Owner -- 定sprint的交付内容, 优先级 Team -- 干活的, ...