Моя дата:
Код: Выделить всё
Thu Mar 28 12:57:32 +06 2024
Код: Выделить всё
[root@cml-p-qv-qapi12 log]# ls -larth /apps/var/log/baseapi.access.log*
-rw-r--r--. 1 web qapps 47M Mar 20 04:00 /apps/var/log/baseapi.access.log-20240320.gz
-rw-r--r--. 1 web qapps 2.6G Mar 26 21:29 /apps/var/log/baseapi.access.log-20240326
-rw-r--r--. 1 web qapps 548M Mar 28 13:04 /apps/var/log/baseapi.access.log
[root@cml-p-qv-qapi12 log]#
Код: Выделить всё
logrotate state -- version 2
"/apps/var/log/baseapi.access.log" 2024-3-27-03:29:1
Код: Выделить всё
/apps/var/log/baseapi.access.log
{
su web qapps
daily
missingok
notifempty
compress
delaycompress
copytruncate
dateext
rotate 180
create 644 web qapps
sharedscripts
postrotate
[ -f "/apps/python3/var/supervisord.pid" ] && /bin/kill -USR2 $(/usr/bin/cat "/apps/python3/var/supervisord.pid" 2> /dev/null) 2> /dev/null || /usr/bin/true
endscript
}
Код: Выделить всё
[root@cml-p-qv-qapi12 logrotate.d]# logrotate -dv supervisor-web-1
reading config file supervisor-web-1
Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /apps/var/log/baseapi.access.log
after 1 days (180 rotations)
empty log files are not rotated, old logs are removed
switching euid to 64918 and egid to 64966
considering log /apps/var/log/baseapi.access.log
log needs rotating
rotating log /apps/var/log/baseapi.access.log, log->rotateCount is 180
dateext suffix '-20240328'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
copying /apps/var/log/baseapi.access.log to /apps/var/log/baseapi.access.log-20240328
truncating /apps/var/log/baseapi.access.log
running postrotate script
running script with arg /apps/var/log/baseapi.access.log
: "
[ -f "/apps/python3/var/supervisord.pid" ] && /bin/kill -USR2 $(/usr/bin/cat "/apps/python3/var/supervisord.pid" 2> /dev/null) 2> /dev/null || /usr/bin/true
"
switching euid to 0 and egid to 0
[root@cml-p-qv-qapi12 logrotate.d]# logrotate -dv supervisor-web-1
reading config file supervisor-web-1
Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /apps/var/log/baseapi.access.log
after 1 days (180 rotations)
empty log files are not rotated, old logs are removed
switching euid to 64918 and egid to 64966
considering log /apps/var/log/baseapi.access.log
log needs rotating
rotating log /apps/var/log/baseapi.access.log, log->rotateCount is 180
dateext suffix '-20240328'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
copying /apps/var/log/baseapi.access.log to /apps/var/log/baseapi.access.log-20240328
truncating /apps/var/log/baseapi.access.log
running postrotate script
running script with arg /apps/var/log/baseapi.access.log
: "
[ -f "/apps/python3/var/supervisord.pid" ] && /bin/kill -USR2 $(/usr/bin/cat "/apps/python3/var/supervisord.pid" 2> /dev/null) 2> /dev/null || /usr/bin/true
"
switching euid to 0 and egid to 0
После ротации содержимое папки остается прежним:
Код: Выделить всё
[root@cml-p-qv-qapi12 log]# ls -larth /apps/var/log/baseapi.access.log*
-rw-r--r--. 1 web qapps 47M Mar 20 04:00 /apps/var/log/baseapi.access.log-20240320.gz
-rw-r--r--. 1 web qapps 2.6G Mar 26 21:29 /apps/var/log/baseapi.access.log-20240326
-rw-r--r--. 1 web qapps 548M Mar 28 13:04 /apps/var/log/baseapi.access.log
[root@cml-p-qv-qapi12 log]#
Подробнее здесь: https://stackoverflow.com/questions/782 ... t-rotating