Plesk Scheduled Task PHP Script

plesk_scheduled_php_task
Plesk Scheduled PHP Task with Arguments

The following Plesk Scheduled Task PHP script can be used to run SQL stored in an external text file via the Plesk Scheduled Tasks option for a specified domain hosted on your Plesk server.

The script accepts an argument which is the name of the SQL script text file to execute. Arguments are passed to the PHP binary in Plesk via the $argv array. An interesting note is that the first element in this array is always the PHP script name.

The script makes the assumption that it is being run from a folder called mw which is in the root of the domain and outside of the public httpdocs folder, but this can be changed to whatever you like.

Currently, the database along with the database username and password are hardcoded but these could easily be parameterised and passed into the code via the Plesk arguments field / $argv array discussed above; It is my intention to modify the code to include this change in a future iteration.

Plesk scheduled task PHP script presented here is useful if you want to run batch data processing jobs on your web server at a pre-defined interval.

Documentation

Click the Webhelp button to view the application help documentation.