I have a Server with a Plesk control panel and I wanted to automate a PHP script using a cron (or crontab). Within Plesk it’s called a scheduled task. The problem is its not that user-friendly (but like everything it’s very easy once you know how) so below is how to do it.

Plesk Cron PHP

In the above screenshot you will see that the fields look pretty straight forward however there are a few tricks you need to know. To get a cron to run every minute, hour, day or month you need to use a asterisk.

Once you’ve set the frequency of the cron you need to call a command. For PHP files you need to do the following:

  • Give the path to the php folder, (usually just php)
  • Type in “-q” (this suppresses the HTTP header output)
  • Finally, give the path to you php file

The example above runs the following script every day at 00:07 in the morning.

php -q httpdocs/crons/stats.php

If you just put the php file into the command it will throw an error.