Settings and troubleshooting · 3 min read

WordPress cron and scheduled tasks

Reminder emails and new bookable dates depend on WordPress scheduled tasks. Here is what each task does, what breaks if they do not run, and how to set up a real server cron job.

In short

HarborBook uses WordPress cron to send reminder and review emails, to keep future dates bookable and to tidy up expired checkout holds. WordPress cron only runs when someone visits the site, so on quiet sites reminders can go out late. For reliable timing, disable the built-in trigger in wp-config.php and call wp-cron.php from a server cron job every few minutes.

What HarborBook schedules

HarborBook uses WordPress’s built-in task scheduler, called WP-Cron. It schedules three kinds of task:

  • Daily slot generation (harborbook_generate_slots_daily, once a day): creates bookable departures from your weekly schedules, as far ahead as the Slot Generation Window under HarborBook → Settings → Booking Rules (90 days by default). This keeps the window moving forward day by day.
  • Release expired holds (harborbook_release_expired_reservations, every 15 minutes): tidies up seats that were held during a checkout that was never finished. Holds stop blocking seats as soon as they expire, so this task is housekeeping only.
  • Scheduled emails (harborbook_send_scheduled_notification, one task per email): sends the 72-hour, 24-hour and 2-hour reminders and the review request for each confirmed booking.

Reminders are scheduled when a booking is confirmed, based on the departure time in your WordPress timezone. A reminder whose time has already passed is not scheduled. At send time, HarborBook skips bookings that have been cancelled or marked as no-show.

How WP-Cron runs

WP-Cron does not run on a clock. WordPress checks for due tasks when someone loads a page on your site. On a busy site this is close to on time. On a quiet site, a 2-hour reminder may go out late, or after the activity has started, if nobody visits in between.

HarborBook does not show a warning when cron is not running, so check it if reminders arrive late or not at all.

What breaks if cron does not run

  • Reminder and review request emails are not sent, or are sent late.
  • New dates stop appearing. Departures are only created as far as the last time slot generation ran. Saving an activity’s schedule creates them again for that activity, but the window does not keep moving forward by itself.
  • Expired checkout holds stay in the database. Guests are not affected.

Confirmation, pending and cancellation emails are sent straight away and do not depend on cron.

Set up a real server cron job

For reliable timing, stop WordPress from running cron on page visits and let your server call it on a fixed schedule instead.

  1. Open the wp-config.php file in the root folder of your WordPress site.
  2. Add this line above the line that says “That’s all, stop editing!”:
define( 'DISABLE_WP_CRON', true );
  1. In your hosting control panel, add a cron job that runs every 5 minutes. Replace example.com with your domain:
*/5 * * * * wget -q -O - "https://example.com/wp-cron.php?doing_wp_cron" >/dev/null 2>&1
  1. If your host has no wget, use curl instead:
*/5 * * * * curl -s "https://example.com/wp-cron.php?doing_wp_cron" >/dev/null 2>&1

Every 5 minutes is a good interval for the 2-hour reminder.

Only add DISABLE_WP_CRON if you also add the server cron job. Without one of the two, no scheduled tasks run at all.

Check that tasks are scheduled

HarborBook has no screen that lists its scheduled tasks. A cron viewer plugin, or the WP-CLI command below, shows them. Look for the three hook names listed at the top of this page.

wp cron event list

Deactivating removes scheduled reminders

When you deactivate HarborBook, it removes all its scheduled tasks, including every pending reminder and review request.

  • When you activate it again, daily slot generation and the 15-minute task are set up again automatically.
  • Reminders for existing bookings are not recreated. A booking gets its reminders again only when it is confirmed again, for example when you click Resend Confirmation on the booking. That also sends the confirmation email to the guest again.

Changing the Reminder Timing settings does not change reminders that are already scheduled. See Choose when reminders are sent.

Was this article helpful?