Logrotate process takes a lot of CPU time

Created:

2016-12-18 06:44:27 UTC

Modified:

2017-08-08 13:33:10 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Logrotate process takes a lot of CPU time

Applicable to:

  • Plesk 12.0 for Linux

Symptoms

Logrotate process takes a lot of CPU resources.

Statistics calculation takes a lot of time to complete because of logrotate process:

# ps auxwfff | egrep 'logrotate|statistics'
root 3432 0.0 0.0 72600 7384 ? S 16:09 0:00 /usr/local/psa/admin/bin/statistics_collector
root 3461 99.9 0.5 292984 287240 ? R 16:09 368:08 \\_ /usr/local/psa/logrotate/sbin/logrotate /usr/local/psa/etc/logrotate.conf -s /usr/local/psa/var/logrotate.status

Logrotate process is trying to read data from non-existing files:

# ps fax | grep logrotate

[root@server1 ~]# strace -s 1024 -p 22574

read(3, "proxy_error_log.1.gz.2.gz.2.gz.3.gz.1.gz.1.gz.2.gz.2.gz.1.gz\\" 2016-11-12\

\"/var/www/vhosts/example.com/statistics/logs/proxy_error_log.1.gz.2.gz.2.gz.3.gz.1.gz.1.gz.2.gz.3.gz\" 2016-11-12\\"/var/www/vhosts/example1.com/statistics/logs/proxy_error_log.1.gz.2.gz.2.gz.3.gz.1.gz.1.gz.3.gz.1.gz.1.gz\" 2016-11-12\\"/var/www/vhosts/example2.com/statistics

Cause

/var/lib/logrotate.status or /usr/local/psa/var/logrotate.status files are too big.Logrotate saves information about all the files ever processed to /var/lib/logrotate.status and /usr/local/psa/var/logrotate.status files. If these files are too big (hundreds of megabytes and more), Logrotate spends a lot of time for reading and checking each entry.

Resolution

Сlean up logrotate.status with the following commands:

  • For /var/lib/logrotate :

    # grep -v '"/var/www/vhosts/system' /var/lib/logrotate.status > /var/lib/logrotate.status.new
    # mv /var/lib/logrotate.status{,.backup}
    # mv /var/lib/logrotate.status.new /var/lib/logrotate.status
  • For /usr/local/psa/var/logrotate.status :

    # grep -v '"/var/www/vhosts/system' /usr/local/psa/var/logrotate.status > /usr/local/psa/var/logrotate.status.new
    # mv /usr/local/psa/var/logrotate.status{,.backup}
    # mv /usr/local/psa/var/logrotate.status.new /usr/local/psa/var/logrotate.status
Have more questions? Submit a request
Please sign in to leave a comment.