How to create Scheduled Tasks in Plesk
In this video I’ll show you how to create Scheulded Tasks in Plesk. I’ll explain where to find them (for admins and customers), how to execute them and what all those cryptic fields mean. I’ll also show you how to mute the output of the commands you execute so you won’t be bothered with emails you didn’t ask for.
Scheduled Task is another name for Cron Job, and it’s something you want to run on a regular basis, like a script file. Plesk itself does not execute your task. Instead it will give you a nice interface to add the parameters you need for the Linux crontab command (or the equivalent on Windows, I believe it’s called at or schtasks).
The cryptic numbers in each field are crontab parameters. Numbers for those fields correspond to their description (i.e. 0-59 for minutes, 0-23 for hours, etc).
One thing of note (and confusion) is how to define endless repetitions. We can do this with the asterisk and slash combinations.
- * means “every”, as in “every minute”, “every hour”, “every day”
- */4 means “every 4”, as in “every 4 hours”
- 5-11 means “every number in between”, such as 5,6,7,8,9,10,11
To find out more about the crontab command, head over to a great nixCraft article here:
By default Plesk will send you an email with any output a script or command may generate. You can avoid this by diverting all output to /dev/null. This is a virtual partition that magically makes things disappear.
In the video I’m using a fictitious script /var/script.php. To divert its potential output I would use
/var/script.php > /dev/null 2>&1
A note about Script Files
If you’re executing BASH, PHP, Python or any other script, make sure your files contain the she-bang at the very beginning to that your server can find the correct path. Here’s an example for how a PHP script should start:
Note that web files that are designed to run in a browser cannot be called that way. You need to call those using cURL or wget.