As a junior high-level PHP programmer, perhaps understand a little Linux knowledge, under the operation of Nginx log cutting
1 #!/bin/bash2 base_path=/www/lisa/logs/lisa.log.log #nginx日志 3 log_path=/data/logs #备份目录 4 date=$ (date-d yesterday +%y%m%d%H). Log #获取日期时间作为文件名 56 mv $base _path $log _path/$date #nginx日志更改名字 78 KILL-USR1 ' cat/usr/local/nginx/logs/nginx.pid ' #-user1 send a signal to Nginx to reopen the log
When executing the command "KILL-USR1 ' Cat/usr/local/nginx/logs/nginx.pid '" (The Nginx.pid file is actually a number), Nginx will be the main process of the PID (process number) is written to the Nginx.pid file, so you can directly manipulate the specified process number by using the Cat command to get its main process number.
finally and add it to a Linux-included scheduled task.
Input CRONTAB-E
Then add the following content:
0 * * * sh/www/lisa/shell/baklog.sh #凌晨0点运行, can be customized here
Nginx Log Cutting