Nginx log is not automatic segmentation according to the date, the feeling will be a problem, so I intend to split the log, in the Internet to find the next, feel very troublesome, to split the log, and then also from the Kai PID, should be good use it, I did not test. It feels too troublesome. I wrote one according to the idea. Also very useful. For everyone's reference.
#!/bin/bash
# The Nginx logs path
Yesterday= ' date-d "Yesterday" +%y%m%d '
Cp/home/log/nginx/logs/access.log/home/log/nginx/logs/access.log. $yesterday
Cat/dev/null >/home/log/nginx/logs/access.log
Note ' This symbol is not a single quote, it is the symbol in front of the number 1.
Idea: The first step is to copy the log for yesterday's log, and the second to empty the log. Done. Good understanding.
stored as SH file, and then added to the crontab inside, just fine. Run every morning.
The command crontab-e enters edit mode and writes the following content. Just fine.
XX * * * */bin/sh/home/sh/cutnginxlog.sh
Run for many days, the effect is good. Hope to be of help to you.
This article is from the "Wu Bin Technical Record" blog, please make sure to keep this source http://bingowu.blog.51cto.com/2758460/1882946
Linux nginx or tomcat log split