lograted日志切割脚本】的更多相关文章

root@op-testsetup-web3.idc1.yiducloud.cn:/etc/logrotate.d# cat etcd /home/work/docker/logs/etcd/preview/etcd2/all.log { copytruncate daily rotate dateext compress delaycompress missingok sharedscripts } 注意: 1.内容时间顺序很重要. 2.copytruncate 参数在置空的时候只是把文件变成…
两种mongo日志切割脚本 vim /etc/logrotate.d/mongodb /home/mongodb/mongolog/mongod.log { daily rotate 7 compress dateext missingok notifempty sharedscripts copytruncate postrotate /bin/kill -SIGUSR1 `cat /home/mongodb/mongodata/mongod.lock 2> /dev/null` 2> /d…
Nginx日志切割脚本: #!/bin/bash ############################################################################# logs_path="/usr/local/nginx/logs" pid_path="/var/run/nginx.pid" backup_dir="/data/log/nginx" [ ! -d $backup_dir ] &&am…
一.日志切割脚本 #!/bin/sh #nginx目录 BASE_DIR=/usr/local/nginx #生成的日志 BASE_FILE_NAME=jonychen.access.log CURRENT_PATH=$BASE_DIR/logs BAK_PATH=$BASE_DIR/datalogs CURRENT_FILE=$CURRENT_PATH/$BASE_FILE_NAME BAK_TIME=`/bin/date -d yesterday +%Y%m%d%H%M` BAK_FILE=…
需求原因:nginx不具备日志切割功能,日志量较大,方便分析. 实现目的:完成nginx日志切割,并根据时间命名   简要命令: mv /usr/local/tengine/logs/access.log /usr/local/tengine/logs/access-date.log kill -USER1 Nginx主进程号.   解释:      通过mv命令重命名日志,并且通过kill -USER1 nginx-id的命令,告诉nginx需要写新的日志, 不然nginx不会在mv之后继续写…
tomcat日志每俩小时切割的脚本如下(这是用定时任务来完成的,此方法无需重启tomcat): time=$(date +%H) end_time=`` a=$end_time BF_TIME=$(-$ cp /usr/local/tomcat8/logs/catalina.out /var/log/tomcat/oldlog/catalina.$BF_TIME.out echo " " > /usr/local/tomcat8/logs/catalina.out #创建存放ca…
#!/bin/bash ip=`ifconfig eth0 | grep "inet addr" | cut -f 2 -d ":" | cut -f 1 -d " "` desHost=10.124.156.244 Date_yestoday=`date -d "-1 day" +%Y%m%d`#设置日志文件存放目录logs_path="/usr/local/nginx/logs/"#设置pid文件pid…
#!/bin/bash NGINX_LOG=/usr/loca/nginx/logs/access.log RE_LOG=/data/backup/`data +%Y%m%d` echo -e "\33[33m begin rotate nginx's logs\33[0m" sleep 5 if [ -d $RE_LOG ];then mkdir -p $RE_LOG fi mv $NGINX_LOG $RE_LOG kill -USR1 `cat /usr/local/nginx/…
#!/bin/shLOG_PATH=/home/test/nginx/logsNEW_LOG_PATH=/home/test/nginx/dayslogNGING_PID=$(cat /home/test/nginx/logs/nginx.pid)  #这步没用DATE=$(date -d "yesterday" +%Y%m%d)    #定义一个昨天的日期mv $LOG_PATH/access.log $NEW_LOG_PATH/access_$(date +%Y%m%d).logk…
tomcat-rotate.sh: #!/bin/bash log_path="/home/tomcat7-api/logs/"expried_time=7 function delete_log() { local currentDate=`date +%s` for file in find $1 -name "*.log" -o -name "*.txt" do local name=$file local modifyDate=$(sta…