admin管理员组文章数量:1289565
I am new with cron jobs and I have to schedule cron jobs. There are a lot of cron jobs in my website which are running randomly but I want all these to run at specific time. Actually I do not want these cron jobs to run at day time and instead I want these to run at night because these are significantly slowing down the server.
Mostly these are firing via plugins so I do not have control over these functions directly.
Is there a way to control schedule for these cron jobs. Your help will be much appreciated.
I am new with cron jobs and I have to schedule cron jobs. There are a lot of cron jobs in my website which are running randomly but I want all these to run at specific time. Actually I do not want these cron jobs to run at day time and instead I want these to run at night because these are significantly slowing down the server.
Mostly these are firing via plugins so I do not have control over these functions directly.
Is there a way to control schedule for these cron jobs. Your help will be much appreciated.
4 Answers
Reset to default 1you could use something like this, WP Crontrol to see what those events might be and when they are scheduled to run ( interval ), but the time of the day ( when they run ) is controlled by visitors viewing your site ( which is why they run during the day, because that when your site has most traffic). The only way around this is to run it server side or a service that provides such actions.
WP Crontrol is a good solution, or you could disable WP-Cron completely and run the cron jobs from the server (or a service like EasyCron) on whatever schedule you want.
To disable WP-Cron, in 'wp-cron.php' add:
define('DISABLE_WP_CRON', true);
Alternatively you can also use Advanced Cron Manager plugin as you can pause any cron events that are running in your site system, and to remove it if you need.
First disable schedule executions as a side effect of normal http requests to your website define('DISABLE_WP_CRON', true);
in wp-config.php
.
Second use wp-cli to execute schedules via crontab -e
.
0 2 * * * wp cron event run --path=/path/to/wp/docroot --due-now
This executes all your schedules at two o'clock. But beware that all schedules will only be executed at this time so you planned post will not be published until two o'clock the next day for example.
本文标签: Scheduling WP cron jobs
版权声明:本文标题:Scheduling WP cron jobs 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741478901a2381049.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论