WordPress Cron & Scheduled Tasks
WordPress uses a pseudo-cron system that relies on site visits to trigger scheduled tasks. WooCommerce Appointments uses WooCommerce's ActionScheduler (built on WordPress cron) to handle time-sensitive operations like email reminders and follow-ups.
How WordPress Cron Works
WordPress cron is not a true cron system. Instead:
- Pseudo-cron: Tasks are scheduled but only run when someone visits your site
- Page load trigger: Each page load checks if any scheduled tasks are due
- Background execution: Tasks run in the background after the page loads
The Problem
WordPress cron is unreliable by default because:
- Tasks only run when someone visits your site
- Low-traffic sites may miss scheduled tasks
- High-traffic sites may experience delays
- Tasks can be skipped if no one visits during the scheduled time
WooCommerce ActionScheduler
WooCommerce Appointments uses ActionScheduler, a more robust scheduling system built on WordPress cron that:
- Stores scheduled tasks in the database
- Provides better error handling and retry logic
- Allows viewing and managing scheduled tasks
- Still relies on WordPress cron to execute tasks
How Appointments Plugin Uses ActionScheduler
The plugin schedules several types of tasks:
Appointment Reminders
- Scheduled X hours/days before the appointment start time
- Configured in WooCommerce → Settings → Emails → Appointment Reminder
- Action:
wc-appointment-reminder
Appointment Completion
- Scheduled at the appointment end time
- Marks appointments as complete automatically
- Action:
wc-appointment-complete
Follow-up Emails
- Scheduled X hours/days after the appointment end time
- Configured in WooCommerce → Settings → Emails → Appointment Follow-up
- Action:
wc-appointment-follow-up
Daily Cleanup
- Removes old in-cart appointments
- Cleans up expired availability rules
- Runs once per day
- Action:
woocommerce_appointments_daily_cleanup
Inactive Cart Removal
- Removes appointments left in cart after the hold period
- Action:
wc-appointment-remove-inactive-cart
Making Cron Reliable
To ensure scheduled tasks run on time, you need to set up a real cron job that triggers WordPress cron independently of site visits.
Option 1: Server-Level Cron Job (Recommended)
Set up a system cron job that runs every minute (or every 5 minutes) to trigger WordPress cron:
For cPanel/Shared Hosting
- Log into your hosting control panel (cPanel, Plesk, etc.)
- Navigate to Cron Jobs or Scheduled Tasks
- Add a new cron job with these settings:
- Frequency: Every minute (
* * * * *) - Command:
/usr/bin/php -q /path/to/your/site/wp-cron.php - Or using
wget:wget -q -O - https://yoursite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1 - Or using
curl:curl -s https://yoursite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
- Frequency: Every minute (
For VPS/Dedicated Server (Linux)
- SSH into your server
- Edit the crontab:
crontab -e - Add this line (runs every minute):
Or using
* * * * * /usr/bin/php -q /path/to/your/site/wp-cron.phpwget:* * * * * wget -q -O - https://yoursite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
Finding Your Site Path
The path to wp-cron.php is typically:
/home/username/public_html/wp-cron.php
or
/var/www/html/wp-cron.php
Replace username and adjust the path based on your hosting setup.
Option 2: Disable WordPress Cron (Advanced)
If you're using a real cron job, you can disable WordPress's pseudo-cron to prevent duplicate executions:
- Add this to your
wp-config.phpfile (before the "That's all, stop editing!" line):define('DISABLE_WP_CRON', true); - Set up the server-level cron job as described in Option 1
Only disable WordPress cron if you've set up a real cron job. Otherwise, scheduled tasks will never run.
Option 3: Using a Plugin
Several plugins can help manage WordPress cron:
- WP Crontrol: View and manage cron events
- Advanced Cron Manager: More advanced cron management
- Action Scheduler: View ActionScheduler tasks (comes with WooCommerce)
These plugins help you monitor cron but don't make it more reliable—you still need a real cron job.
Verifying Cron is Working
Check ActionScheduler Status
- Install the Action Scheduler plugin (if not already installed with WooCommerce)
- Go to Tools → Scheduled Actions in WordPress admin
- Look for tasks like:
wc-appointment-reminderwc-appointment-follow-upwoocommerce_appointments_daily_cleanup
Check Cron Execution
- Install WP Crontrol plugin
- Go to Tools → Cron Events
- Verify that
wp_schedule_eventandaction_scheduler_run_queueare running regularly
Test Email Reminders
- Create a test appointment scheduled for tomorrow
- Set reminder time to "1 hour" before appointment
- Wait and verify the reminder email is sent exactly 1 hour before
Troubleshooting
Reminders Not Sending
- Check cron is running: Verify your server cron job is active
- Check email settings: Ensure reminder emails are enabled in WooCommerce settings
- Check ActionScheduler: View scheduled actions to see if reminders are queued
- Check server logs: Look for PHP errors that might prevent execution
Tasks Running Late
- Low traffic: If your site has low traffic, tasks may be delayed until someone visits
- Solution: Set up a real cron job (see Option 1 above)
Duplicate Tasks
- Multiple cron triggers: If both WordPress cron and server cron are active, tasks might run twice
- Solution: Disable WordPress cron (
DISABLE_WP_CRON) and use only server cron
Best Practices
- Always use a real cron job for production sites
- Monitor scheduled tasks regularly using Action Scheduler
- Test email reminders after setting up cron
- Keep backups of your cron configuration
- Document your cron setup for your team
Summary
- WordPress cron is unreliable by default (requires site visits)
- WooCommerce Appointments uses ActionScheduler for better task management
- Set up a real server cron job to ensure tasks run on time
- Monitor scheduled tasks using Action Scheduler or WP Crontrol
- Test your setup to verify reminders and follow-ups work correctly
For appointment-based businesses, reliable cron is essential to ensure customers receive timely reminders and follow-up communications.