In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the nginx log regular backup and deletion of how to configure the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe that after reading this nginx log regular backup and deletion how to configure the article will have a harvest, let's take a look.
Once the nginx log feature is enabled, nginx will generate log files of a certain size every day. If the system runs stably and there is no problem, then the log basically will not be checked. However, if these logs are not cleaned in time and accumulated day by day, it will be scary to occupy the disk space of the server. To solve this problem, use the shell script to back up and delete the nginx log files regularly, only for a period of time.
Figure 1:
#! / bin/bash#auth:lzq#desc: back up the current log by date and regenerate the next day's log file # date:2016-09-18date= `date +% y% m% d`nginx _ pid= `cat / var/run/ nginx.pid` # exit if ["$?"! = 0] then exit 1 if the current nginx is not running The path where fi#nginx logs are located: log_path='/usr/local/nginx/logs/'log_name='access.log'mv ${log_path} ${log_name} ${log_path} ${log_name} $date# delete the old backup file function deloldbak () {olddate= `date + "% y%m%d"-d "- $1 day" `if [- e "${log_path} ${log_name} $olddate"] Then rm-f ${log_path} ${log_name} $olddate echo "${log_path} ${log_name} $olddate del ok" fi} # reload nginx configuration Regenerate the nginx log file kill-usr1 $nginx_pidif ["$?" = = 0] then deloldbak 7 exit 0 This is the end of fi's article on "how to configure regular backup and deletion of nginx logs". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to configure regular backup and deletion of nginx logs". If you want to learn more, you are welcome to follow the industry information channel.
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.