• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Input Enabling and Configuring Logroation via CLI

Aakhyan

New Pleskian
Server operating system version
CentOS Linux release 7.9.2009
Plesk version and microupdate number
Plesk Obsidian 18.0.50.2
Hi Pleskians,

I was wondering if there was any option to enable the logroation by size on each domains via CLI?
The GUI method (Domains > example.com > Websites & Domains > Logs > Manage Log Files > Log Rotation) is painstakingly very time consuming, if you thing about 100+ domains.

The server settings option (Tools & Settings > Server Settings > Force daily log rotation for all domains and specify how long logs will be kept) is only basis the number of days the file should be kept but does not have the option to rotate basis the size.

Can you suggest if there are any ways? If so that would be very helpful.
 

Attachments

  • Screenshot 2023-03-26 at 9.49.57 AM.png
    Screenshot 2023-03-26 at 9.49.57 AM.png
    109.9 KB · Views: 1
Hi Pleskians,

There is a slight change to the command as suggested by IgorG.

The -log-bytime value when used at the end overrides the -log-bysize value.
# for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e "select name from domains"`; do /usr/local/psa/bin/site --update $i -log-rotate true -log-bysize 1G -log-max-num-files 3 -log-bytime monthly -log-compress true; done

Furthermore, as per the article we can modify as below with Plesk's inbuilt CLI:
plesk bin domain -l| while read dom_name; do plesk bin domain -u $dom_name -log-rotate true -log-bysize 500M -log-max-num-files 7 -log-compress true; done
The above command sets the following values:
Log Rotation = True
Log rotation condition = By size (size here set to 500 Mb)
Maximum number of log files = 7
Compress log files = True
Email the log files = False (as we haven't set that in the above command).

However, if you had the email-id set earlier, use the below set of commands:
plesk bin site --list > /root/domains.txt <-------- Create a list of all domains
cat /root/domains.txt | while read i; do plesk bin site -u $i -log-email ""; done <-------- Run the command to disable sending notifications

Post the above settings I got the desired log rotation (snapshot attached for reference).

Cheers!;)
 

Attachments

  • Screenshot 2023-03-26 at 10.55.58 AM.png
    Screenshot 2023-03-26 at 10.55.58 AM.png
    106.7 KB · Views: 1
Back
Top