Как использовать logrotate для вырезания лог-файлов uwsgi
Мой путь к журналу uwsgi.log: /root/code/script/uWSGI.log
Мой журнал о конфигурации uwsgi:
in /etc/logrotate.d/uwsgi
/root/code/script/uWSGI.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 640 root root
sharedscripts
postrotate
touch /root/code/script/.touchforlogrotate
endscript
}
Мой uwsgi.ini
[uwsgi]
http = 0.0.0.0:8050
socket=/root/code/script/uwsgi.sock
master=true
chdir=/root/code/
wsgi-file=/root/code/data_analysis/wsgi.py
home = /root/anaconda3/envs/data-analysis
worker=6
threads=2
max-requests=5000
thunder-lock=true
enable-threads=true
pidfile=/root/code/script/uwsgi.pid
touch-logreopen = /root/code/script/.touchforlogrotate
Когда я использую команду logrotate -d /etc/logrotate.d/uwsgi
, возникает следующая ошибка
reading config file uwsgi
error: uwsgi:2 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:3 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:4 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:5 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:6 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:7 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:8 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:9 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:10 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:11 lines must begin with a keyword or a filename (possibly in double quotes)
error: uwsgi:12 lines must begin with a keyword or a filename (possibly in double quotes)
Reading state from file: /var/lib/logrotate/status
Allocating hash table for state file, size 64 entries
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Handling 1 logs
rotating pattern: /root/code/script/uWSGI.log 1048576 bytes (no old logs will be kept)
empty log files are rotated, old logs are removed
considering log /root/code/script/uWSGI.log
Creating new state
Now: 2024-08-16 17:17
Last rotated at 2024-08-16 17:00
log needs rotating
rotating log /root/code/script/uWSGI.log, log->rotateCount is 0
dateext suffix '-20240816'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /root/code/script/uWSGI.log.1 to /root/code/script/uWSGI.log.2 (rotatecount 1, logstart 1, i 1),
renaming /root/code/script/uWSGI.log.0 to /root/code/script/uWSGI.log.1 (rotatecount 1, logstart 1, i 0),
log /root/code/script/uWSGI.log.2 doesn't exist -- won't try to dispose of it
renaming /root/code/script/uWSGI.log to /root/code/script/uWSGI.log.1
disposeName will be /root/code/script/uWSGI.log.1
removing old log /root/code/script/uWSGI.log.1
error: error opening /root/code/script/uWSGI.log.1: No such file or directory
Я написал этот файл конфигурации после поиска соответствующей информации о logrotate в Интернете, но я не могу найти соответствующий документ, который сообщил об ошибке, могу ли я спросить, есть ли какая-либо проблема с моей конфигурацией? Как ее следует изменить?