0

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 4

1

you 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.

0

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);
0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.