simple001
Nginx 错误日志切割  将此脚本放到crond中循环执行
1 #!/usr/bin/bash         
2 NGINX_PID=/usr/local/nginx/logs/nginx.pid
3 NGINX_COM=/usr/local/nginx/sbin/nginx
4 LOGS_DIR=/usr/local/nginx/logs
5 LOGS_NAME=error.log
6 BLOCK_IP_FILE=/usr/local/nginx/conf/blockip.conf
7 cd $LOGS_DIR
8 /usr/bin/mv $LOGS_NAME $(/usr/bin/date +%F-%H -d "last hour").$LOGS_NAME && /usr/bin/kill -USR1 $(cat $NGINX_PID) > BLOCK_IP_FILE && $($NGINX_COM -s reload)

 

分类:

技术点:

相关文章:

  • 2021-07-15
猜你喜欢
  • 2021-09-17
  • 2021-12-24
  • 2021-08-12
  • 2022-02-23
  • 2021-12-18
  • 2021-10-03
相关资源
相似解决方案