LoginSignup
6
5

More than 5 years have passed since last update.

wp-cliでwp-cronを強制的に発火する

Posted at

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を指定してプラグインのアップデートを発火させた。

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5