Marinus Klasen

Marinus Klasen

  • WordStress
  • Development
  • Consultancy
  • Developer Resources
  • Blog
  • Contact

March 15, 2022

Re-scheduling a cronjob in WordPress with WP-CLI

Marinus Klasen

Sometimes cronjobs are scheduled when a plugin is activated, and that time is not always the preferred time, especially when you’re running a daily event.

Using WP-CLI to list cron events

wp cron event list

Output

+------------------------------------+---------------------+-----------------------+------------+
| hook                               | next_run_gmt        | next_run_relative     | recurrence |
+------------------------------------+---------------------+-----------------------+------------+
| wp_privacy_delete_old_export_files | 2022-03-15 15:38:49 | 33 minutes 18 seconds | 1 hour     |
| wp_https_detection                 | 2022-03-15 15:38:49 | 33 minutes 18 seconds | 12 hours   |
| wp_version_check                   | 2022-03-15 15:38:49 | 33 minutes 18 seconds | 12 hours   |
| wp_update_plugins                  | 2022-03-15 15:38:49 | 33 minutes 18 seconds | 12 hours   |
| wp_update_themes                   | 2022-03-15 15:38:49 | 33 minutes 18 seconds | 12 hours   |
| recovery_mode_clean_expired_keys   | 2022-03-15 15:38:49 | 33 minutes 18 seconds | 1 day      |
| wp_scheduled_delete                | 2022-03-15 15:38:51 | 33 minutes 20 seconds | 1 day      |
| delete_expired_transients          | 2022-03-15 15:38:51 | 33 minutes 20 seconds | 1 day      |
| wp_scheduled_auto_draft_delete     | 2022-03-15 15:38:53 | 33 minutes 22 seconds | 1 day      |
| wolkloos_check_weather             | 2022-03-15 20:19:29 | 5 hours 13 minutes    | 1 day      |
| wp_site_health_scheduled_check     | 2022-03-21 15:38:49 | 6 days                | 1 week     |
+------------------------------------+---------------------+-----------------------+------------+

It’s the wolkloos_check_weather event I was looking for.

Unschedule the event

wp cron event unschedule wolkloos_check_weather

Reschedule the event with your own time

wp cron event schedule wolkloos_check_weather 06:00 daily

Output after reschedule

+------------------------------------+---------------------+----------------------+------------+
| hook                               | next_run_gmt        | next_run_relative    | recurrence |
+------------------------------------+---------------------+----------------------+------------+
| wp_privacy_delete_old_export_files | 2022-03-15 15:38:49 | 35 minutes 1 second  | 1 hour     |
| wp_https_detection                 | 2022-03-15 15:38:49 | 35 minutes 1 second  | 12 hours   |
| wp_version_check                   | 2022-03-15 15:38:49 | 35 minutes 1 second  | 12 hours   |
| wp_update_plugins                  | 2022-03-15 15:38:49 | 35 minutes 1 second  | 12 hours   |
| wp_update_themes                   | 2022-03-15 15:38:49 | 35 minutes 1 second  | 12 hours   |
| recovery_mode_clean_expired_keys   | 2022-03-15 15:38:49 | 35 minutes 1 second  | 1 day      |
| wp_scheduled_delete                | 2022-03-15 15:38:51 | 35 minutes 3 seconds | 1 day      |
| delete_expired_transients          | 2022-03-15 15:38:51 | 35 minutes 3 seconds | 1 day      |
| wp_scheduled_auto_draft_delete     | 2022-03-15 15:38:53 | 35 minutes 5 seconds | 1 day      |
| wolkloos_check_weather             | 2022-03-16 06:00:00 | 14 hours 56 minutes  | 1 day      |
| wp_site_health_scheduled_check     | 2022-03-21 15:38:49 | 6 days               | 1 week     |
+------------------------------------+---------------------+----------------------+------------+

Find more information on how WP-CLI and cron schedules work here:
https://developer.wordpress.org/cli/commands/cron/event/

How to run all cron events in WordPress via WP-CLI?

Run wp cron event run --due-now

How to run a specific cron event in WordPress via WP-CLI, regardless of it’s schedule?

Run wp cron event run your_cron_event

About Marinus Klasen

Marinus has been working in software/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge.

Marinus Klasen on Twitter

Looking for a WordPress expert?
Hire top notch developers on Codeable!

Consult an expert

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get in touch

Contact me using the details below

Marinus Klasen

Wilhelmina van Pruisenweg 35, 2595 AN Den Haag

marinus@mklasen.com
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • Elementor Widget UsageMarch 27, 2025
  • Programmatically showing popups with ElementorMarch 25, 2025
  • The Elementor sanitize_settings errorSeptember 12, 2024
  • Announcing.. Wooping Shop Health!June 13, 2024
  • Swiper setup when using wp-scriptsMarch 14, 2024

Copyright © 2025 ยท Marinus Klasen | Webdesign by Team Rood