Problem Description
- Log rotation is not working on a Plesk server
Problem Resolution
Disable and re-enable log rotation in Plesk. Go to the domain in Plesk, choose Logs > Log Files dropdown in upper right corner > Log Rotation and ensure it’s configured sanely. If it’s more than one domain, you can do this for all of them via shell with this:
for DOMAIN in $(plesk bin domain -l); do
plesk bin site -u $DOMAIN -log_rotate false
plesk bin site -u $DOMAIN -log_rotate true
done
# Force 30 days log rotation server-wide
plesk bin settings -s logrotate_force=true plesk bin settings -s logrotate_period=30
You can alternatively configure Plesk to force log rotation via GUI (alternative to the last command above).
If the file taking up a ton of space does *not* end in .processed, run the following commands:
DOMAIN=mydomain.com
plesk sbin statistics --calculate-one --domain-name=$DOMAIN
/usr/local/psa/logrotate/sbin/logrotate /usr/local/psa/etc/logrotate.d/$DOMAIN
If the file taking up a ton of space is only those ending with .processed, run this to have logrotate run on its own:
DOMAIN=mydomain.com
/usr/local/psa/logrotate/sbin/logrotate /usr/local/psa/etc/logrotate.d/$DOMAIN
Or have Plesk do this for all domains at once with this command:
plesk daily ExecuteStatistics
If the above command doesn't do the trick try these instead:
/usr/local/psa/admin/sbin/statistics --calculate-all
/usr/local/psa/logrotate/sbin/logrotate /usr/local/psa/etc/logrotate.d/*
Details on how Plesk manages log rotation here.