Articles in this section

How to execute a command on all domains using a particular Service Plan in Plesk?

kb: how-to Plesk for Linux

Applicable to:

  • Plesk for Linux

Question

How to execute a command on all domains using a particular Service Plan in Plesk?

Answer

  1. Run the following command to create a list of all domains under a Service Plan, Unlimited in this example, and place them into a file called list.txt.

    Note: Change Unlimited to the name of the desired Service Plan

    # plesk db "SELECT cl.id AS 'Client ID', cl.pname AS 'Name', cl.login AS 'Login', d.id AS 'Domain ID', d.name AS 'Domain', FROM_UNIXTIME(Limits.value) AS 'Exp date', Templates.name AS 'service plan', ROUND(d.real_size/1024/1024,2) AS 'disk usage (MB)', cl.vendor_id AS 'Belongs to', d.status AS 'Status', ip.ip_address AS 'IPv4/IPv6', round(sum(dtf.http_in)/1024/1024,2) AS 'HTTP_IN (MB)', round(sum(dtf.http_out)/1024/1024,2) AS 'HTTP_OUT (MB)' FROM DomainServices ds,IpAddressesCollections ipc, IP_Addresses ip, clients cl, domains d LEFT JOIN Subscriptions as s ON d.id=s.object_id LEFT JOIN PlansSubscriptions AS pls ON s.id=pls.subscription_id LEFT JOIN Templates ON pls.plan_id=Templates.id LEFT JOIN SubscriptionProperties AS sp ON s.id=sp.subscription_id LEFT JOIN Limits ON sp.value=Limits.id left join DomainsTraffic AS dtf on d.id=dtf.dom_id WHERE (sp.name='limitsId' OR sp.name IS NULL) AND (Limits.limit_name='expiration' OR Limits.limit_name is NULL) AND (Templates.type <> 'domain_addon' OR Templates.type IS NULL) AND d.id = ds.dom_id AND d.cl_id = cl.id AND ds.type = 'web' AND ds.ipCollectionId = ipc.ipCollectionId AND ip.id = ipc.ipAddressId group by d.id" | grep Unlimited | awk -F'|' '{print $6}' | cut -d' ' -f2 > list.txt

  2. Pass this list to a command. In this example, the command turns on the mail service for all domains listed.

    # while read -r i; do plesk bin subscription -u "$i" -mail_service true; done < list.txt

    Note: This command can be altered to run any other command that calls for a domain or subscription name. The variable $i should be placed where the domain name would normally be included.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.