手动

  • 创建 shell 文件 ```shell

    !/bin/bash

    L0G_PATH=”/var/log/nginx/“ RECORD_TIME=$(date -d “yesterday” +%Y-%m-%d+%H:%M) PID=/var/run/nginx/nginx.pid mv ${L0G_PATH]/access.1og ${L0G_PATH}/access.${RECORD_TIME}.1og mv ${L0G_PATH]/error.1og ${L0G_PATH}/error.${RECORD_TIME}.10g

向Mginx主进程发送信号,用于重新打开日志文件

ki11 -USR1 cat $PID ```

  • 添加可执行权限

    chmod +x xxx.sh

自动

  • 扔到 crontab