A cron job runs a command or PHP file automatically at set intervals. For example, it can take a backup every night, process an e-mail queue every 15 minutes or run WordPress scheduled tasks.
Creating a cron job in Plesk
- Go to Websites & Domains > Scheduled Tasks.
- Click Add Task.
- Choose the task type: Run a PHP script, Fetch a URL or Run a command.
- Enter the file path or address, choose how often it runs and click OK.
Creating a cron job in cPanel
- Go to Advanced > Cron Jobs.
- Choose the frequency from Common Settings (e.g. Once Per Hour).
- Type the command in the Command field and click Add New Cron Job.
Example commands
Running a PHP file:
/usr/local/bin/php /home/username/public_html/cron.php
Calling an address:
wget -q -O /dev/null https://yourdomain.com/cron.php
The full PHP path may differ depending on the server and PHP version. In Plesk, the "Run a PHP script" option fills in the path for you.
How to read the time expression
The five fields mean minute, hour, day of month, month, day of week, in that order.
*/15 * * * *: every 15 minutes0 3 * * *: every day at 03:000 9 * * 1: every Monday at 09:00
Tip for WordPress
WordPress's own scheduler (wp-cron) runs on every page load and can slow your site down. Add the line define('DISABLE_WP_CRON', true); to wp-config.php and create a cron job on the server that calls wp-cron.php every 15 minutes. For details, see our article on wp-cron.php.
Please note
Running tasks more often than needed (such as every minute) can use up your account's resource limits.
