Among the virtues I have to rescue Plesk with respect to other control panels is that most, if not all, management tasks can be performed both from the Web interface or from the line command.
Among the commands are not well documented is the "event_handler" that allows us, from the command line, run our script after some predefined events are held Plesk.
In this way we can create special directories after creating a mail account, change directory permissions after you create a domain, or to generate a notice to be carried out a management task.
To list the tasks already defined:
/ usr / local / psa / bin /
event_handler-l / usr / local / psa / bin / event_handler -
list and we're going to find a solution as the following:
Id: 2
Name: Service stopped
Priority: 0
User: root
Command: / usr / local / psa / admin / bin / modules / watchdog / wd - unmonit-service = \u0026lt;new_service> - plesk-name
This is an example of a task should be performed every time you stop a service, and to be precise is the module Watchdog to stop monitoring the service if it has stopped.
The event "Service stopped" is one of the more than 100 events that are already predefined by Plesk, and each has a unique code and list them in order to use the command:
/ usr / local / psa / bin / event_handler
le / usr / local / psa / bin / event_handler - list-events
Creating a task To create task will use the option "-
c " or "
- create " passing some arguments but, as for example:
/ usr / local / psa / bin / event_handler-c-priority 10-user root-command "/ usr / local / own / procmail_spam.sh \u0026lt;new_mailname> "-event 52
With this we will create a new command (option "-
c "to create and"
-command "to specify which command to execute) to execute each time you create a new user (52
-event" is "
Mail account created ").
With this command we also specify that users must run this command, which in our case is the" root "(" -
root user. ") To view the users list may perform any of the scheduled tasks:
/ usr / local / psa / bin / event_handler-lu
/ usr / local / psa / bin / event_handler - list-users
If we are to run multiple tasks or commands in base an event, which comes into play is the priority (in this example "10
-priority") which is an integer value ranging from 0 to 100, with the lowest priority commands which will run first.
Each own variables handles events related to the event which is being carried out, these variables can be passed to the commands that we will execute. In our example the event is to create a new mailbox, and the only variable that has this event is "\u0026lt;new_mailname>
."
variables on each of the events I did not find much official information, but an old hand in line Plesk 8.3
But they also work for versions of Plesk 8.6 and 9.2
Modifying an existing task To modify or delete an existing task using the "-d" or "-u" for remove or delete a task and indicating the same ID. In this way to delete a task we could use the commands:
/ usr / local / psa / bin / event_handler-d 2
/ usr / local / psa / bin / event_handler - 2
delete or change the priority we will use :
/ usr / local / psa / bin / event_handler - or 2-
priority 10 / usr / local / psa / bin / event_handler - update 2-10
priority