Published on
What cron jobs are needed for
A cron job is a task that the server runs automatically at set times - without anyone having to open the site. Typical use cases on web hosting:
- Reliably publishing scheduled posts and newsletters
- Triggering nightly backups or database clean-ups
- Importing product data, prices or dates from an external source
- Emptying caches regularly
- Shop tasks such as stock reconciliation or reminders about abandoned orders
Create a task in Plesk
- Open the Scheduled Tasks in Plesk.
- Click Add Task.
- Choose the type - more on that below.
- Enter the target: the path to the script or the address to be called.
- Set the schedule.
- Save - and run the task once manually to see whether it does what it should.
The last point is the most important: otherwise, a cron job that silently fails at night is only noticed when someone spots the missing results.
Which type to choose?
- Run a PHP script. The usual choice for tasks within your website. You enter the path relative to the subscription, such as
/httpdocs/wp-cron.php. The script runs directly via the PHP interpreter - without a time limit imposed by the web server, which is the decisive advantage for longer tasks. - Fetch a URL. Calls an address as if a visitor were opening the page. Practical if an extension explicitly specifies a call address for its cron. Disadvantage: the same time limits apply as for a normal page view.
- Run a command. For cases where a command-line call is needed, such as cleaning up a directory.
Set the schedule
For the schedule, Plesk offers predefined intervals - hourly, daily, weekly - and also the classic cron notation with five fields:
minute hour day of month month weekday
| Expression | Meaning |
|---|---|
*/15 * * * * | every 15 minutes |
0 * * * * | hourly on the hour |
30 3 * * * | daily at 3:30 am |
0 4 * * 1 | Mondays at 4:00 am |
0 5 1 * * | on the 1st of every month at 5:00 am |
Put compute-intensive tasks at night and avoid the full hour - experience shows that most jobs start at the same time there. A time such as 3:17 am is less crowded than 3:00 am. The server time is German time (Europe/Berlin).
Offload WordPress cron properly
WordPress brings its own scheduler, but it is not a real cron: wp-cron.php is checked on every page view. That has two disadvantages - on a rarely visited site, scheduled tasks run late or not at all, and on a heavily visited site, the check runs unnecessarily often.
The clean solution consists of two steps:
- Switch off the built-in trigger in
wp-config.php:define('DISABLE_WP_CRON', true); - Create a task in the Plesk task scheduler that runs
/httpdocs/wp-cron.phpas a PHP script - for most sites, an interval of 15 minutes is enough.
The result: scheduled posts appear on time, newsletters go out reliably, and the site is no longer slowed down by the cron check on normal page views. How to set up WordPress in the first place is described in Install WordPress.
When a cron job does not run
- Wrong path. The most common mistake. The path is given relative to the subscription, not as a full web address - typically
/httpdocs/.... - Script aborts halfway. With longer tasks, time and memory limits apply. Both can be raised in the domain's PHP settings, see Change the PHP version and settings.
- Wrong PHP version. Check whether the task runs with the same PHP version as your website.
- No feedback. Enable notification by email - then you receive the script's output and see error messages immediately.
- Task runs twice. An interval that is too short for a long-running task causes runs to overlap. Increase the interval or build a lock into the script.
Cron jobs are also a good tool for backups: a nightly database dump is quickly set up - what else belongs in a backup is covered in Create and restore backups.
Frequently asked questions
Task scheduler in every plan
The task scheduler is part of Plesk and included in all web hosting plans - with no limit on the number of tasks and at no extra cost.
View web hosting plans & pricesRent web hosting
from €1.99 / month
Prepaid without a contract, Plesk included, hosted in Frankfurt am Main.
View plans & pricesRead more
- Web hosting - plans & prices
- Install WordPress
- Create & restore backups
- Change the PHP version
- Create a MySQL database
Discover more