Plesk

How to change log rotation settings in Plesk for all domains at once?

Question

How to change log rotation settings in Plesk for all domains at once?

Answer

It can be performed using Plesk command line utility or Plesk API-XML request:

Command line utility for Linux:

Connect to the server via SSH and use the following command change log rotation setting for all domains:

# plesk bin domain -l| while read dom_name; do plesk bin domain -u $dom_name -log-bytime weekly; done

This command is switching log rotation condition to By time and sets log rotation period as 1 week.

To disable sending email about rotated log for all domains at once:

  • Create list of all domains on the server:

    # plesk bin site --list > /root/domains.txt

  • Run the command to disable sending notifications:

    # cat /root/domains.txt | while read i; do plesk bin site -u $i -log-email ""; done

Get an additional information about the plesk bin domain utility options by the following command:

# plesk bin domain --help

Also, it is possible to use CLI commands to update rotation settings on a service plan level, or on a domain/subscription level. For example, to enable log rotation on the domain example.com once the current log file reaches the 200 KB size (by-size rotation), use the following command:

# plesk bin subscription -u example.com -log-bysize 200K

To enable weekly log rotation (by-time rotation) on the domain example.com:

# plesk bin subscription -u example.com -log-bytime weekly

To enable log rotation once the current log file reaches the 20 KB size on websites created by users of the plan Plan 1:

# plesk bin service_plan -u "Plan 1" -log_bysize 20K

To set weekly log rotation for subscriptions created by the plan Plan 1:

# plesk bin service_plan -u "Plan 1" -log-bytime weekly

Visit Reference for Command-Line Utilities for Linux guide for additional details about 'plesk bin service_plan -u' and 'plesk bin subscription -u' commands options.

Command line utility for Windows

Connect to the server via RDP and use the attached file in order to change log rotation setting for all or several websites.

Unzip the .bat file, run it as Administrator and follow the instructions inside.

Using Plesk API request

Modify log rotation settings using Plesk API request.

Send the API request to Plesk website. In the following example, XML API request changes log rotation setting for all domains of admin account

<packet version="1.6.3.0">
<log-rotation>
<set>
<filter>
<owner-id>1</owner-id>
</filter>
<settings>
<log-condition>
<log-bytime>Weekly</log-bytime>
</log-condition>
</settings>
</set>
</log-rotation>
</packet>

This API request switch log rotation condition to By time and sets log rotation period as 1 week.

Exit mobile version