Cobra Forum

Plesk Panel => Plesk Service/Interface => Topic started by: mahesh on Oct 07, 2024, 08:58 AM

Title: Log rotation doesn't work for a particular domain in Plesk:error creating output
Post by: mahesh on Oct 07, 2024, 08:58 AM
Symptoms

#/usr/local/psa/logrotate/sbin/logrotate -v -f /usr/local/psa/etc/logrotate.conf
copying /var/www/vhosts/system/example.com/logs/error_log to /var/www/vhosts/system/example.com/logs/error_log.1
error: error creating output file /var/www/vhosts/system/example.com/logs/error_log.1: File exists

Cause
Temporary logrotate files were not removed due to an unexpected interruption of the log rotation task.

Resolution
1.Connect to the server via SSH

2.Find the temporary logrotate files causing this issue:

Note: The temporary logrotate files can be identified by suffix ".1"

#ls -lha /var/www/vhosts/system/*/logs/*.[0-9]
-rw-r--r-- 2 root root 0 nov 4 2020 /var/www/vhosts/system/example.com/logs/error_log.1
-rw-r--r-- 2 root root 0 nov 2 2020 /var/www/vhosts/system/example.com/logs/proxy_error_log.1
-rw-r--r-- 2 root root 0 nov 2 2020 /var/www/vhosts/system/example.com/logs/access_log.processed.1
3.Rename the invalid temporary logrotate files:

#find /var/www/vhosts/system/*/logs/*.[0-9] -exec mv {} {}.invalid \;
4.Run the logrotate utility to verify the logs are rotated as expected:

#/usr/local/psa/logrotate/sbin/logrotate -v -f /usr/local/psa/etc/logrotate.conf