Nginx 访问日志轮询切割脚本

--------------------------------------------------------------------
注:如果你对python感兴趣,我这有个学习Python基地,里面有很多学习资料,感兴趣的+Q群:895817687
--------------------------------------------------------------------
1 #!/bin/sh2 Dateformat=`date +%Y%m%d`3 Basedir="/application/nginx"4 Nginxlogdir="$Basedir/logs"5 Logname="access_www"6 [ -d $Nginxlogdir ] && cd $Nginxlogdir||exit 17 [ -f ${Logname}.log ]||exit 18 /bin/mv ${Logname}.log ${Dateformat}_${Logname}.log9 /bin/mv access_bbs.log ${Dateformat}_access_bbs.log
10 /bin/mv access_blog.log ${Dateformat}_access_blog.log
11 $Basedir/sbin/nginx -s reload

配置www.conf

1 [root@lnmp02 scripts]# vim /application/nginx/conf/extra/www.conf 2  server {3         listen       80;4         server_name  www.judong.org judong.org;5         location / {6             root   html/www;7             index  index.html index.htm;8         }9         access_log logs/access_www.log main;
10   }

配置bbs.conf

1 [root@lnmp02 scripts]# vim /application/nginx/conf/extra/bbs.conf 2     server {3         listen       80;4         server_name  bbs.judong.org;5         location / {6             root   html/bbs;7             index  index.html index.htm;8         }9        access_log logs/access_bbs.log main;  ##添加访问日志
10   }
11 ~

配置blog.conf

 1 [root@lnmp02 scripts]# vim /application/nginx/conf/extra/blog.conf   2 server {3         listen       80;4         server_name  blog.judong.org;5         location / {6             root   html/blog;7             index  index.html index.htm;8         }9  access_log logs/access_blog.log main;
10   }

测试

 1 [root@lnmp02 scripts]# ll /application/nginx/logs/2 total 403 -rw-r--r--. 1 root root   756 Mar  3 22:07 20160315_access_www.log 4 -rw-r--r--. 1 root root     0 Mar 15 09:27 20160316_access_www.log5 -rw-r--r--. 1 root root     0 Mar 17  2016 20160317_access_bbs.log6 -rw-r--r--. 1 root root     0 Mar 17  2016 20160317_access_blog.log7 -rw-r--r--. 1 root root     0 Mar 17  2016 20160317_access_www.log8 -rw-r--r--. 1 root root     0 Mar 17  2016 access_bbs.log9 -rw-r--r--. 1 root root     0 Mar 17  2016 access_blog.log
10 -rw-r--r--. 1 root root 22177 Mar  3 22:06 access.log
11 -rw-r--r--. 1 root root     0 Mar 17  2016 access_www.log
12 -rw-r--r--. 1 root root  2088 Mar 17  2016 error.log
13 -rw-r--r--. 1 root root     5 Mar  3 19:31 nginx.pid

配置定时任务使得每天0点整执行脚本

1 [root@lnmp02 scripts]# crontab -l
2 ######cut nginx access_www.log########
3 00 00 * * *  /bin/sh /server/scripts/cut_nginx_log.sh >/dev/null 2>&1

Nginx 访问日志轮询切割相关推荐

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

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

  2. apache的“按周配置访问日志轮询”,需要安装cronolg软件

    在学习第9课课前×××时,3月18日遇到过的1个问题有必要记录一下. 在这部分的答案讲解视频里,最后1题的"上机考试"题,第2题要求:apache的虚拟主机"按周配置访问 ...

  3. apache虚拟主机、日志轮询、日志统计、去版本优化

    一.虚拟主机 1.基于域名的虚拟主机 www.zhang.com   /var/html/www blog.zhang.com  /var/html/blog bbs.zhang.com   /var ...

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

    2019独角兽企业重金招聘Python工程师标准>>> 11月27日任务 12.10 Nginx访问日志 12.11 Nginx日志切割 12.12 静态文件不记录日志和过期时间 1 ...

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

    - 12.10 Nginx访问日志 - 12.11 Nginx日志切割 - 12.12 静态文件不记录日志和过期时间# 12.10 Nginx访问日志 - 日志的格式- vim /usr/local/ ...

  6. 6月8日任务(12.10 Nginx访问日志 12.11 Nginx日志切割 12.12 静态文件)

    课程名称:12.10 Nginx访问日志 笔记内容: [root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf 定义日志格式 combined_ ...

  7. 笔记12(36-40)域名重定向,用户认证,nginx访问日志,日志切割

    学习笔记 域名重定向 配置第二个域名: vi /etc/nginx/conf.d/blog.aminglinux.cc.conf 在server_name 那一行的域名后面加一个域名,空格作为分隔 n ...

  8. 使用Nginx访问日志统计PV和UV

    一个网站当用户量增大时候,不可避免有统计pv和uv的需求. UV(Unique Visitor):独立访客,以cookie为依据区分不同访客,UV计算一天之内(00:00-24:00),访问网站的访客 ...

  9. Apache服务一日志轮询(cronolog)

    1.cronolog介绍 2.安装日志轮询工具cronolog 3.修改配置文件(%Y%m%d 按天轮询) 4.重启Apache服务 5.测试 6.轮询时间 6.1按周建立目录按天轮询 6.2按小时轮 ...

最新文章

  1. (轉貼) Embedded System與System on Chip的差異 (IC Design)
  2. IDEA第一个mybatis程序 mybatis增删查改操作 mybatis的map模糊查询
  3. 计算机领域的范式,编程领域的范式转移
  4. access数据库应用系统客观题_随访数据库的建立:易侕DataWeb系统应用
  5. MySQL的binlog及关闭方法
  6. android源码下载过程的一些注意事项,windows下载android源码
  7. 中国首个 SaaS 模式的云告警平台 iOS 版 APP 上线
  8. 一个神奇的???whatever~~
  9. mysql sam和db_Mysql
  10. 一步一步理解日历calendar(一)
  11. python二维图自动保存_Autodesk Inventor工程图自动保存PDF文件iLogic代码
  12. 6678与FPGA PCIE调试
  13. 宝藏又小众的室内场景unity3d模型素材网站分享
  14. 神经计算棒python_Intel 最新的神经元计算棒Movidius Neural Compute Stick能干什么 ?
  15. 关于ROHDESCHWARZ公司电流探头EZ-17系数修正的说明
  16. javascript 字符串的排列与组合
  17. python 爬虫论_python爬虫——论抓包的正确姿势和学好Javascript的重要性(1)
  18. C#:实现Zhang Suen细化算法(附完整源码)
  19. SRAM FPGA控制,实际产品拷机测试过
  20. 2021年5月16日 星期日 阴

热门文章

  1. shell mysql t e_shell操作mysql 将查询结果导出
  2. 微服务架构下的安全认证与鉴权
  3. 《移动项目实践》实验报告——Android数据存储
  4. C++——赫夫曼编码-译码器(Huffman Coding)
  5. Bounce 弹飞绵羊
  6. JVM调优技巧与经验
  7. Apache Hive on Apache Tez
  8. 回溯算法【0-1背包问题】
  9. 【CentOS Linux 7】实验4【Shell编程】
  10. 一元多项式计算器 :加、减、乘运算【完整代码+运行截图+实验说明】