Skip to content

Setting Up a Reliable Server Cron

Some Sunshine features do their work in the background instead of making your customer wait. Background downloads build large zip files behind the scenes and email a link when it's ready, and delayed image processing resizes uploads after the fact. Both rely on WordPress's built-in scheduler, called WP-Cron.

The catch with WP-Cron is that it only runs when someone visits your site. On a busy site that's usually fine. But if your site has quiet stretches, or a lot is happening at once (like a big gallery upload), a queued download can sit and wait longer than you'd expect before its "ready" email goes out.

Setting up a real server cron fixes this. Instead of depending on a visitor, your server runs the scheduler on a fixed timer. This is not required. Sunshine works out of the box on WP-Cron. But if you sell large downloads or your site isn't busy around the clock, it's worth the few minutes to set up.

Step 1: Turn off the built-in WP-Cron

Add this line to your wp-config.php file, just above the line that says /* That's all, stop editing! */:

define( 'DISABLE_WP_CRON', true );

Learn how to add this custom code to your WordPress website

This stops WordPress from running the scheduler on page visits, so it only runs from the real cron you're about to set up. If you skip this step things still work, but the scheduler can end up running twice and wasting resources.

Step 2: Set up the cron job

You have two options depending on your web host.

Option A: Your host's cron tool (cPanel)

Most hosts include a cron tool. In cPanel it's under Advanced > Cron Jobs.

Add a new job set to run every minute, using this command (swap in your real domain):

wget -q -O - "https://YOURSITE.com/wp-cron.php?doing_wp_cron" >/dev/null 2>&1

Learn how to add this custom code to your WordPress website

That's it. Your server will now trigger the scheduler once a minute.

Option B: A free external cron service

If your host doesn't offer a cron tool, a free service like cron-job.org does the same thing from the outside.

  1. Create a free account.
  2. Add a new cronjob pointing at https://YOURSITE.com/wp-cron.php?doing_wp_cron (use your real domain).
  3. Set it to run every minute, or every 5 minutes if the free plan doesn't allow every minute.
  4. Save it.

How often should it run

Background downloads check their queue on a one-minute schedule, so every minute is the best match and keeps things moving quickly. Every 5 minutes is fine too if you don't mind the small extra wait.

Checking that it works

Queue up a large download, or upload images with delayed processing turned on, and check back in a minute or two. If the download email arrives, or the uploaded images show their thumbnails, your cron is running.

Still need help?

If you have not yet found your answer in the documentation articles, please contact support

Sunshine Photo Cart for WordPress