Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize nginx log file segmentation in Linux

Shulou Source: shulou.com Published: 2022-06-02 10:28:46 10月03日 Update

In this issue, the editor will bring you about how to achieve nginx log file segmentation in Linux. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Step 1:

Vi / etc/logrotate.d/nginx

The script content is as follows

/ usr/local/nginx/logs/access.log {dailyrotate 7missingoknotifemptydateextsharedscriptspostrotate if [- f / usr/local/nginx/logs/nginx.pid]; then kill-USR1 `cat / usr/local/nginx/logs/ nginx.pid`fiendscript}

Step 2: test for availability

/ usr/sbin/logrotate-f / etc/logrotate.d/nginx

Step 3: configure scheduled tasks (vi / etc/crontab)

0 * / usr/sbin/logrotate-f / etc/logrotate.d/nginx above is how to split nginx log files in the Linux shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Content steps documents logs analysis specialties small and medium-sized tasks rich content that is articles more knowledge articles scripts industries perspectives information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Information Linux Apple macOS