Applicable to:
- Plesk for Linux
Question
- How to configure log rotation in Plesk for Linux?
- How does log rotation work?
Answer
Log rotation is an automated process in which log files are compressed, moved (archived), renamed, or deleted once they become too old or too big, depending on the configuration. The log rotation is being triggered by the Daily Maintenance script. More info can be found in the documentation.
Licensing
Free
Where to set up log rotation in the GUI
Global: Tools & Settings > Server Settings > Force daily log rotation for all domains.
Service plan level: Service Plans > service_plan_name > Logs & Statistics > Log Rotation
Domain level: Domains > example.com > Logs > Log Rotation
Log rotation utility
RPM
/usr/local/psa/logrotate/sbin/logrotate
APT
/opt/psa/logrotate/sbin/logrotate
Logs
Logrotate does not log anything by default
Debug
Run in debug mode manually and check for errors:
Note: The command flags -d
and --debug
don't rotate the log files, it's just for testing purposes (implies -v
)
# logrotate -d /etc/logrotate.conf
Configuration
/usr/local/psa/etc/logrotate.conf
Vhosts configuration files
# cat /usr/local/psa/etc/logrotate.conf | grep include
include /usr/local/psa/etc/logrotate.d (by default)
Global log rotation config
/etc/logrotate.conf
Services configuration files
# cat /etc/logrotate.conf | grep include
/etc/logrotate.d (by default)
# ls -l /etc/logrotate.d
-rw-r--r--. 1 root root 160 Sep 19 2018 chrony
-rw-r--r--. 1 root root 194 Aug 6 13:44 httpd
-rw-r--r--. 1 root root 893 Aug 8 11:49 mariadb
-rw-r-----. 1 root named 514 Aug 8 12:16 named
-rw-r--r--. 1 root root 94 Oct 2 05:54 nginx
-rw-r--r--. 1 root root 203 Oct 30 2018 php-fpm
-rw-r--r--. 1 root root 211 Aug 30 05:38 plesk-php71
-rw-r--r--. 1 root root 211 Sep 27 04:42 plesk-php72
-rw-r--r--. 1 root root 211 Sep 27 04:42 plesk-php73
-rw-r--r--. 1 root root 149 Sep 30 11:06 sw-cp-server
-rw-r--r--. 1 root root 114 Aug 2 08:46 sw-engine
-rw-r--r--. 1 root root 207 Oct 8 14:50 syslog
-rw-r--r--. 1 root root 100 Oct 30 2018 wpa_supplicant
-rw-r--r--. 1 root root 103 Aug 8 11:57 yum
CLI
All log rotation commands are available here:
https://docs.plesk.com/en-US/obsidian/cli-linux/using-command-line-utilities/site-sites.67067/
To activate for one domain:
# plesk bin domain -u example.com -log-rotate true
To activate log rotation for all domains:
# plesk bin domain -l | while read dom_name; do plesk bin domain -u $dom_name -log-rotate true; done
API
No
Investigation tips
1. Check rotation status:
# cat /usr/local/psa/var/logrotate.status | grep "/var/www/vhosts/system/example.com"
2. Check that rotation config exists
# ls -la /usr/local/psa/etc/logrotate.d/ | grep example.com
Comments
0 comments
Please sign in to leave a comment.