uWSGI日志按照日期自动切割

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

posted @ 2020-07-04 14:35  Jerome12138  阅读(1249)  评论(0)    收藏  举报