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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM