首页 > 系统相关 >nginx 日志备份

nginx 日志备份

时间:2023-11-16 15:14:09浏览次数:32  
标签:logs 备份 access nginx newAccessLog 日志 log

·1、编辑脚本backup.sh

#!/bin/bash

#进入备份目录

cd /data/nginx/logs/

#设置备份名字
newAccessLog="access`date +%Y-%m-%d`.log"
newErrorLog="error`date +%Y-%m-%d`.log"

#拷贝日志文件,已经在配置文件设置日志文件存放在:/data/nginx/logs/ 下,如果没有修改日志路径的一般在:/usr/local/nginx/logs/

cp -rf access.log $newAccessLog

cp -rf error.log $newErrorLog

#cp -rf /usr/local/nginx/logs/access.log $newAccessLog

#cp -rf /usr/local/nginx/logs/error.log $newErrorLog

#清空日志文件

cat /dev/null > access.log
cat /dev/null > error.log

#cat /dev/null > /usr/local/nginx/logs/access.log

#cat /dev/null > /usr/local/nginx/logs/error.log

 #压缩拷贝好的日志文件

tar -zcvf $newAccessLog.tar.gz $newAccessLog --remove-files
tar -zcvf $newErrorLog.tar.gz $newErrorLog --remove-files

 

2、添加计划任务

crontab -e:30 3 * * * sh /data/nginx/logs/backup.sh

翻译

搜索

复制

标签:logs,备份,access,nginx,newAccessLog,日志,log
From: https://www.cnblogs.com/leihongnu/p/17836274.html

相关文章

  • nginx 定时重启
    1、编写脚本nginx_restart.sh#!/bin/bashps-ef|grepnginx|grep-vgrep>/data/nginx/nginx_restart.txtfile=$(cat/data/nginx/nginx_restart.txt|grepprocess|grep-vnginx_restart|awk'{print$2}')file_num=`cat/data/nginx/nginx_restart.......
  • nginx 日志查询
    转载:https://www.jianshu.com/p/f105fb19dd0b1、根据访问IP统计UVawk'{print$1}'access.log|sort|uniq-c|wc-l2、统计访问URL统计PVawk'{print$7}'access.log|wc-l3、查询访问最频繁的URLawk'{print$7}'access.log|sort|uniq-c|sort-n-k1-r|m......
  • skywalking(二) 实现基于nginx+java服务的全链路数据收集
    实现nginx+jenkins全链路数据追踪1.部署JenkinsIP:10.0.0.941.1安装、配置jenkins#1.安装jdk11aptupdateaptinstall-yopenjdk-11-jdk#2.下载tomcatmdkir/apps&cd/appswgethttps://dlcdn.apache.org/tomcat/tomcat-8/v8.5.93/bin/apache-tomcat-8.5.93.tar.g......
  • goldengate add trandata显示最小附加日志already enable,但是info trandata显示disabl
    问题描述:数据库版本11.2.0.4,操作系统版本:windowsserver2012,goldengate版本12.1.2.1.0在给ogg同步表添加trandata的时候,提示supplementalredologdataisalreadyenabled。但是使用infotrandata查看的时候,却显示supplementalredologdataisdisabled。  这时通过......
  • nginx配置kibana访问用户名和密码认证、及无认证访问配置
    在nginx上配置kibana页面访问时,默认是采用kibana的认证,一般直接安装kibana后,是没有用户名和密码认证的。如果要在负载均衡上配置反向代理和用户认证,可按以下步骤进行配置:1.安装Nginx:首先,确保已经安装了Nginx,并且可以正常访问Kibana页面。2.生成密码文件:使用htpa......
  • RMAN-ERROR:因为找不到过期和丢失的归档日志而备份失败
    oracleRMANERRORoracle采用rman备份,但是备份过程中报错如下:RMAN-00571:===========================================================RMAN-00569:===============ERRORMESSAGESTACKFOLLOWS===============RMAN-00571:========================================......
  • web nginx 大量time_wait 几乎没有establish
     #!/usr/bin/python#-*-coding:utf-8-*-#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#@auhorbyruiy####pipinstallparamiko-ihttps://pypi.tuna.tsinghua.edu.cn/simple##pipinstallpsutil-ihttps:/......
  • nginx安装ssl模块
    一、引言当我们的Linux服务器上当中发布了web项目,有时候需要配置一个SSL证书,来使用https,然而我们一开始编译的Nginx的时候并没有把SSL模块一起编译进去.二、如何补装SSL模块既然在安装的时候没有编译ssl,难道把nginx卸载重新安装一次?不不不,我们只需要在原有的基础上添加ssl模块......
  • Widows环境下安装Nginx并配置开机自启
    1下载Nginx下载地址:http://nginx.org/en/download.html2启动Nginxnginx的启动方式有两种:一种是直接点击nginx.exe启动,另一种是通过命令行启动2.1直接启动找到nginx目录,双击nginx.exe即可启动2.2命令行启动在nginx目录地址栏输入cmd,进入cmd窗口输入下列命令行nginx.exe或者st......
  • 机器码备份_二
    [yhzr]有意合作联系扣扣:1176769884$$$AA24C7BD5A0A8FE8E06E1FB53BBE8AD4:00|66|88_CF4DF748256261B751D029853C3DA5BC:00|01|02|03|04|10|11|12|13|14|20|21|22|23|24|30|31|32|33|34|40|41|66|88_80F90FC9A3100B423F6AD58EBA7AB875:00|01|02|03|04|10|11|12|13|14|20|21|22|23|2......