uWSGI日志按照日期切割
[uwsgi]
http=0.0.0.0:9000
chdir=/root/hello
wsgi-file=hello/wsgi.py
processes=4
threads=1
master=True
pidfile=uwsgi.pid
daemonize=uwsgi.log
touch-logreopen =/root/hello/.touchforlogrotat
注: 【uwsgi.ini 新增配置選項】
# 日志文件
aemonize=/root/hello/uwsgi.log
# 生成一個監聽的文件,
# touch .touchforlogrotat 相當於修改了創建時間,系統會重新reload日志
touch-logreopen =/root/hello/.touchforlogrotat
logbackups.sh
#!/bin/bash
LOGDIR="/root/hello/" # uwsgi.log路徑
DATE=`date -d "yesterday" +"%Y-%m-%d"`
NEWDIR="/root/Logs/${DATE}" # uwsgi.newlog 路徑
mkdir -p ${NEWDIR}
mv ${LOGDIR}/uwsgi.log ${NEWDIR}/uwsgi-${DATE}.log
touch /root/hello/.touchforlogrotat # .touchforlogrotat 路徑
crontab -e
0 0 * * * sh /root/hello/logbackups.sh
參考傳送門:
普通日志與uwsgi日志的轉儲
uwsgi log rotate按天切割日志
django-crontab
linxu-crontab