What is a scheduled task?
A scheduled task is a job that runs by itself at a time you choose. It is like an alarm clock that starts a program. On Linux, this feature is called cron. A cron job might clear old files each night or run a PHP script every hour.
Steps
- Log in to Plesk.
- Click Tools & Settings and then Scheduled Tasks. For one website, open Websites & Domains and click Scheduled Tasks under your domain.
- Choose the system user the task will run as. Use the user of your website.
- Click Add Task.
- Choose a Task type. There are three kinds: Run a command, Run a PHP script and Fetch a URL.
- Enter the command, script path or web address in the box.
- Pick when it should run. You can choose Cron style and fill the five time fields, or pick a simple option like daily.
- Add an optional description, so you remember what the task does.
- Click OK.
How the time fields work
Cron style has five fields. In order: minute, hour, day of month, month, day of week. A star * means every.
30 2 * * *
This runs the task at 2:30 in the morning, every day.
*/15 * * * *
This runs the task every 15 minutes.
Example task
/usr/bin/php /var/www/vhosts/example.com/httpdocs/cron.php
This runs a PHP file called cron.php. Replace the path with your own. The PHP path may differ on your server, so ask Hostvento support if it fails.
Tip: Click Run Now beside a task to test it. Turn on the notification setting, so Plesk emails you the output or any errors.
Quick recap
- Scheduled tasks run commands at set times.
- Find them under Scheduled Tasks.
- Choose the task type, the command and the time.
- Test with Run Now.