Setting Up Cron Jobs in Enhance

Schedule recurring tasks for your website using the built-in cron manager.

Web Hosting Updated 22 September 2024

Cron jobs let you run a PHP script, URL, or shell command on a schedule - for example, sending scheduled emails, clearing cache, or running WordPress's background tasks.

Adding a Cron Job in Enhance

  1. Log in to web.teklanhosting.co.uk.
  2. Click your website, then go to Advanced → Developer tools → Cron jobs.
  3. Click Add cron job.
  4. Enter the command (run command or request URL) and set the interval.
  5. Save.

The cron jobs list shows each job's run command or request URL alongside its interval.

Cron Schedule Syntax

Cron schedules use five fields: minute, hour, day of month, month, day of week.

*  *  *  *  *
│  │  │  │  └── Day of week (0-7, Sunday = 0 or 7)
│  │  │  └───── Month (1-12)
│  │  └──────── Day of month (1-31)
│  └─────────── Hour (0-23)
└────────────── Minute (0-59)

Common examples:

* * * * *       Every minute
*/5 * * * *     Every 5 minutes
0 * * * *       Every hour (on the hour)
0 0 * * *       Every day at midnight
0 3 * * 1       Every Monday at 3am
0 0 1 * *       First day of every month at midnight

WordPress Cron (WP-Cron)

WordPress uses a pseudo-cron system that runs when someone visits the site. On low-traffic sites this can be unreliable. The recommended fix is to disable WP-Cron in wp-config.php and run it via a real server cron:

  1. Add this line to wp-config.php (before /* That's all */):
    define('DISABLE_WP_CRON', true);
  2. In Enhance, add a cron job with this command (replace the path with your actual path - check the Enhance file manager):
    /usr/bin/php -q /var/www/[your-site-uuid]/public_html/wp-cron.php
    Set the interval to every 5 minutes: */5 * * * *

Cron Job Output

By default, cron output is discarded. To capture it for debugging, redirect to a log file:

/usr/bin/php -q /path/to/script.php >> /home/username/logs/cron.log 2>&1

Remember to clear or rotate this log file periodically so it does not fill your disk quota.