Nginx log segmentation Abstract: nginx does not support log segmentation, but its PID can be used to achieve log segmentation. I have read several online examples, but they are not clear. So I decided to write one by myself. Maybe I forgot one day and can start learning again. I hope I can make it clear that I will not bother to watch it next time or when others are watching it. Because nginx does not support log segmentation, its PID can be used to achieve log segmentation. 1. write the log Separation program nginx-log.sh #/bin/bash savepath_log = '/logs/nginx/logs' # The path where the log will be stored nglogs ='/usr/local/nginx/logs' # nginx log Path mkdir-p $ savepath_log/$ (date + % Y) /$ (date + % m) mv nglogs/access. log % savepath_log/$ (date + % Y)/$ (date + % m)/access. % (data + % Y % m % d ). log mv nglogs/error. log % savepath_log/$ (date + % Y)/$ (date + % m)/error. % (data + % Y % m % d ). log kill-USR1 'cat/usr/local/nginx/logs/nginx. pid '# Save the script and add it to cront in linux The AB daemon allows this script to be executed at every day to split logs every day. 2. Modify the File Permission so that it can be executed. Chmod 755 nginx-log.sh 3. you can check which scheduled tasks are crontal-l 4. open the daemon and enter crontal-e # In programming mode. For example, press I with vi. add the task to be executed in the daemon, usually the log is divided at 0 0 0 ****/logs/nginx/nginx-log.sh # The execution file storage path is good, wait until tomorrow to go to the log directory to see the implementation results ..