Nginx 日志文件切割

/usr/local/nginx/logs/下添加cut-log.sh文件


LOGS_PATH=/home/wwwlogs
YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)
mv ${LOGS_PATH}/1889.com.log ${LOGS_PATH}/1889.com_${YESTERDAY}.log
kill -USR1 $(cat /usr/local/nginx/logs/nginx.pid)

在命令crontab -e下添加
0 0 * * * /bin/bash /usr/local/nginx/sbin/cut-log.sh  


下面的是每秒种向demo.txt添加hello world

*/1 * * * * echo "hello world" >>/home/demo/demo.txt

你可能感兴趣的:(Nginx 日志文件切割)