- Plesk for Linux
A GDPR-related regulation prohibits storing clients' IP address on the server after a certain period of time. How to set up forced log rotation for all domains?
via Plesk interface:
- Login into Plesk;
- Go to Tools & Settings > Server Settings;
- Enable option Force daily log rotation for all domains and specify how long logs will be kept:
via command line:
Login server via SSH;
Run the following command to enable force log rotation:
# plesk bin settings -s logrotate_force=true
Specify how long logs will be kept:
# plesk bin settings -s logrotate_period=12
Obtaining the script
1. Log in to the Plesk via SSH as root or under another additional administrative account.
2. Download the script and store it somewhere on the file system outside the Plesk directory (
/opt/force-log-rotation.sh, for example):
# cd /opt
# wget https://support.plesk.com/hc/en-us/article_attachments/360006154673/enforce-log-rotation.tar.gz
3. Unpack the script and make it executable:
# tar -zxvf enforce-log-rotation.tar.gz && chmod +x enforce-log-rotation.sh
Configuring the period of storing immediately
To immediately configure the period of storing the rotated logs for existing domains, run the script manually. In the example below, the domains are set up to store rotated logs for one day:
# ./enforce-log-rotation.sh 1
Configuring the period of storing automatically
To configure the period of storing the rotated logs for existing and new domains, create a scheduled task. To schedule the task, put a cron script into /etc/cron.d .
In the example below, the script will run every midnight and set the one-day long period of storing the logs:
# Enforce log rotation ``for
# Min Hour Day Month DoW
00 00 * * * root /opt/force-log-rotation.sh
Note: Do not forget to replace
/opt/force-log-rotation.sh with the actual name of the script including the full path and add the desired number of days you wish to store the rotated logs for (by default, they are stored for one day).
If desired, edit the cron file to change the frequency of the script running.
Note: changing to to '* * * * *' will result in the script being run every minute (not recommended).
Note: Once the script is executed, subscriptions will be marked as
Locked, because the script changes subscriptions settings.