TFT

CRON Expressions for WordPress

Generate CRON expressions for WordPress cron jobs. Schedule plugin tasks, update checks, or backups using the correct syntax for wp-cron.php. Essential for WordPress developers.

CRON for WordPress Cron Jobs
Templates for wp-cron.php, WP-CLI tasks, and WordPress maintenance
WordPress Configuration
Customize the templates for your WordPress installation
WP-Cron Hourly Events
Process hourly scheduled events
0 * * * *

Every hour on the hour

curl -s https://example.com/wp-cron.php > /dev/null 2>&1

Default WordPress cron processing

Disable WP-Cron + System Cron
Use system cron instead of WP-Cron
*/15 * * * *

Every 15 minutes

/usr/local/bin/wp cron event run --due-now

Recommended production setup

Daily WordPress Backup
Daily database and files backup
0 2 * * *

Daily at 2:00 AM

wp db export /backups/wp-db-$(date +%Y%m%d).sql --path=/var/www/html && \ tar -czf /backups/wp-files-$(date +%Y%m%d).tar.gz /var/www/html/wp-content

Regular WordPress backups

Update Check
Check for WordPress updates
0 6 * * 1

Every Monday at 6:00 AM

/usr/local/bin/wp core check-update && /usr/local/bin/wp plugin list --update=available

Weekly update notifications

Auto Apply Updates
Automatically apply safe updates
0 4 * * 0

Every Sunday at 4:00 AM

/usr/local/bin/wp core update && /usr/local/bin/wp plugin update --all && /usr/local/bin/wp theme update --all

Automated maintenance

Clear Cache
Clear WordPress object cache
0 0 * * *

Daily at midnight

/usr/local/bin/wp cache flush

Cache maintenance

Database Optimization
Optimize WordPress database
0 3 * * 0

Every Sunday at 3:00 AM

/usr/local/bin/wp db optimize && /usr/local/bin/wp db clean

Database maintenance

Security Scan
Run security vulnerability scan
0 5 * * 1

Every Monday at 5:00 AM

/usr/local/bin/wp plugin list --format=json | wp vuln check

Security monitoring

Clean Transients
Remove expired transients
0 1 * * *

Daily at 1:00 AM

/usr/local/bin/wp transient delete --expired

Database cleanup

Log Rotation
Rotate WordPress debug logs
0 0 1 * *

1st of every month at midnight

mv /var/www/html/wp-content/debug.log /var/www/html/wp-content/debug-$(date +%Y%m).log

Log management

Site Health Check
Run WordPress health checks
0 */6 * * *

Every 6 hours

/usr/local/bin/wp health check status

Monitoring site health

Regenerate Sitemap
Regenerate XML sitemap
0 4 * * *

Daily at 4:00 AM

/usr/local/bin/wp yoast seo regenerate

SEO maintenance

WordPress Cron Jobs Explained

WordPress uses cron jobs for scheduled tasks: publishing scheduled posts, checking for updates, sending email notifications, and running backups. The WordPress cron generator provides ready-to-use expressions for common WP tasks.

Unlike system cron, WordPress's built-in WP-Cron only runs when someone visits the site. For reliable scheduling, you disable WP-Cron and set up real system cron jobs that call wp cron event run --due-now via WP-CLI.

Common WordPress cron schedules:

  • Process due events - */15 * * * * (every 15 minutes)
  • Daily backup - 0 2 * * * (2 AM daily)
  • Weekly update check - 0 6 * * 1 (Monday 6 AM)
  • Hourly health check - 0 * * * * (every hour)

The generator outputs both the cron expression and the exact command to run, whether that's WP-CLI for local tasks or curl for triggering WP-Cron remotely.

When You'd Actually Use This

Moving from WP-Cron to system cron

Your low-traffic site misses scheduled posts because WP-Cron only fires on pageviews. Set up system cron to reliably process scheduled events every 15 minutes.

Automating WordPress backups

Schedule daily database dumps and weekly full backups. The generator provides commands using WP-CLI or mysqldump with proper paths.

Running maintenance tasks

Clear transients weekly, optimize database monthly, flush caches daily. System cron ensures these run even when you don't visit wp-admin.

Managing multiple WordPress sites

Run the same cron jobs across 10 client sites. Standardize backup times, update checks, and monitoring across your entire portfolio.

Scheduling content publishing

Your editorial team schedules posts for specific times. System cron ensures they publish on schedule, not "whenever the next visitor arrives".

Automating plugin-specific tasks

WooCommerce scheduled emails, membership expirations, subscription renewals—all rely on cron. System cron makes them reliable.

What to Know Before Using

Disable WP-Cron first.Add define('DISABLE_WP_CRON', true); to wp-config.php before setting up system cron. Otherwise, you'll process events twice.

WP-CLI must be installed.Commands like wp cron event run require WP-CLI. Install it (wp cli info to verify) and note the full path (often /usr/local/bin/wp).

Set the correct working directory.WP-CLI commands need to run from your WordPress root. Either cd into the directory in your cron command, or use the --path=/var/www/html flag.

Configure email for output.Cron emails command output to the server's admin. Redirect output (> /dev/null 2>&1) if you don't want emails, or set up proper log files.

Production tip: Test WP-CLI commands manually before adding to crontab. Run sudo -u www-data wp cron event list to verify permissions and paths work correctly.

Common Questions

Why disable WP-Cron?

WP-Cron only runs when someone visits the site. Low-traffic sites miss scheduled events. High-traffic sites run WP-Cron too frequently. System cron provides predictable, controlled execution.

How often should I run WordPress cron?

Every 15 minutes is the WordPress default and works for most sites. For time-sensitive tasks (scheduled posts, expiring memberships), consider every 5 minutes.

What user should run WordPress cron jobs?

Run as the web server user (www-data, apache, or nginx) so file permissions match. Example: sudo -u www-data wp cron event run.

Can I run different cron jobs for different sites?

Yes, use the --path flag to specify each site's directory. Set up separate cron entries for each WordPress installation on your server.

How do I see what cron events are scheduled?

Run wp cron event list to see all scheduled events with their next run times. Use wp cron event run --due-now to execute any that are due.

What if my cron job fails?

Cron will email you the error (if configured). Check that WP-CLI is in the PATH, the WordPress directory exists, and the web server user has correct permissions.