wp-cliでwp-cronの一覧を取得
wp-cronに登録されているイベントの一覧を取得するには以下のようにwp cron event list
を使用する。
$ wp cron event list
+----------------------+---------------------+----------------------+---------------+
| hook | next_run_gmt | next_run_relative | recurrence |
+----------------------+---------------------+----------------------+---------------+
| wp_maybe_auto_update | 2015-02-05 07:35:00 | 4 minutes 46 seconds | 12 hours |
| wp_update_plugins | 2015-02-05 08:50:13 | 1 hour 19 minutes | 12 hours |
| wp_update_themes | 2015-02-05 08:50:13 | 1 hour 19 minutes | 12 hours |
| wp_scheduled_delete | 2015-02-05 08:54:23 | 1 hour 24 minutes | 1 day |
| wp_version_check | 2015-02-05 19:29:58 | 11 hours 59 minutes | 12 hours |
| publish_future_post | 2020-01-01 12:00:18 | 4 years 11 months | Non-repeating |
+----------------------+---------------------+----------------------+---------------+
wp-cliで特定のイベントを強制的に発火させる
特定のイベントを発火させるには、上述のコマンドで発火させたいイベントのhook
を確認した後で、以下のようにwp cron event run
を実行する。
$ wp cron event run wp_update_plugins
Success: Executed the cron event 'wp_update_plugins'
上の例では、引数にwp_update_plugins
を指定してプラグインのアップデートを発火させた。