Search Knowledge base

Does WP CRON work on Pressidium?

Can I use WP CRON ? I see DISABLE_WP_CRON is TRUE in wp-config


The short answer is yes! You can use wp-cron exactly like you used to, we’ve only improved the way wp-cron is triggered. 


How the default wp-cron trigger mechanism works


Scheduling jobs like publishing a post on a specific date and time, or running maintenance jobs, are critical for many websites. WordPress supports the creation of virtual cron jobs using the wp-cron.php file. It allows you to register a scheduled task and WordPress will trigger your job based on the registered schedule. 

By default WordPress triggers wp-cron.php everytime someone visits your website and checks if a scheduled job is present and if it should run it now or not.

This creates problems for both low and high traffic sites. For low traffic sites you may have scheduled a job to run every hour but you may not get a visit for hours, so wp-cron.php won’t get triggered and your hourly job will not run on each hour as you intended it to. For high traffic sites you’ll trigger wp-cron.php on each visit, leading to unnecessarily increased resource usage thus making your website slower. 


How we improved the wp-cron triggering mechanism


We haven’t done anything extraordinary, we decided to just use the well known and stable Linux native CRON service. On each website creation we provision a special linux cron entry which triggers wp-cron.php every five minutes. This will ensure that your jobs will run as scheduled without overloading your website. 

Since we use an external system to trigger wp-cron.php there is no point on leaving the default WordPress triggering mechanism for wp-cron in place, so we’ve disabled it. That’s the reason you may see in your wp-config.php the entry DISABLE_WP_CRON => TRUE, which only affects the triggering mechanism and doesn’t break your wp-cron functionality at all.