In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The realization method of automatic cutting of nginx Generation Log under Linux
1. Edit the shell program of the cutting log and customize the directory.
# vi / data/nginx/cut_nginx_log.sh
Enter the code:
#! / bin/bash # This script run at 00:00 function cutAccess () {dir=$1 newdir= "${dir} / $(date-d" yesterday "+"% Y ") / $(date-d" yesterday "+" m ")" suffix=$ (date-d "yesterday" + "% Y%m%d") mkdir-p $newdir mv ${dir} / access.log ${newdir} / access.$suffix.log} CutAccess "/ home/wwwlogs/www.yourdomain.com/" cutAccess "/ home/wwwlogs/www.yourdomain-1.com/" cutAccess "/ home/wwwlogs/www.yourdomain-2.com/" # restart nginx kill-HUP `cat / usr/local/nginx/logs/nginx.pid `
2. Add scheduled tasks and cut automatically at 0 o'clock every day.
# crontab-e 0 0 * / bin/bash / data/nginx/cut_nginx_log.sh
3. Nginx log format
Log_format access'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"''$http_user_agent "$http_x_forwarded_for'; access_log / home/wwwlogs/www.yourdomain.com/access.log access
If you have any questions, please leave a message or go to the community to exchange and discuss, thank you for reading, hope to help you, thank you for your support!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.