Deisred log is not rotating

22 Views Asked by At

I was trying to rotate a log file, But seems it does not work. Attaching all the artifacts. Please check below:

My date:

Thu Mar 28 12:57:32 +06 2024

Contents of folder:

[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]#

Contents of /var/lib/logrotate/logrotate.status

logrotate state -- version 2
"/apps/var/log/baseapi.access.log" 2024-3-27-03:29:1

Log rotation config:

/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
}

Run manually:

[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

It says, log is rotating. But log is not rotating.

After run rotation, contents of folder are still same:

[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]#

Plese help me.

0

There are 0 best solutions below