LoginSignup
13
13

More than 5 years have passed since last update.

wp-cron を正確な時刻で実行する

Posted at

wp-cron だとサイトにアクセスがあるまで登録したタスクが起動しないというのがあります。それを正確な時刻で実行したいときの Tips です。

その方法ですが、まず wp-config.php に、

define('DISABLE_WP_CRON', true);

と書いてサイトアクセス時の wp_cron 起動を無効化した後、Linux などの crontab の仕組みを使って、

wget http://example.com/wp-cron.php

のように指定時刻に直接 wp-cron.php にアクセスすればオッケーです。今は wget より curl なのかな。

WordPress を操作するスクリプトを直接 crontab に登録しちゃうという手もありますけど、wp-cron の仕組みをお手軽に使うのも良いと思います。

13
13
1

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
13
13