{"id":93,"date":"2021-10-14T10:46:58","date_gmt":"2021-10-14T10:46:58","guid":{"rendered":"http:\/\/wappoblog.lndo.site\/?post_type=docs_wappo&p=93"},"modified":"2022-01-17T14:45:55","modified_gmt":"2022-01-17T14:45:55","slug":"wp-cron","status":"publish","type":"docs_wappo","link":"https:\/\/wappoblog.lndo.site\/docs\/wp-cron\/","title":{"rendered":"Running WordPress scheduled tasks on time"},"content":{"rendered":"\n
When you own a website, speed and reliability<\/strong> are the 2 parameters you must provide for an optimal user experience; failing to do so will result in losing business.<\/p>\n\n\n\n Wappointment is designed in a way that long-lasting processes or processes relying on external services are placed in a queue. These processes then can be run later on in a background task, this generates 2 benefits:<\/p>\n\n\n\n WordPress has a built-in system to handle our scheduled background tasks. Each of the plugins you have installed on your site may run scheduled tasks in the background.<\/p>\n\n\n\n The default system in WordPress is relying on your site\u2019s traffic, the higher the traffic the bigger the chance your background scheduled tasks will run on time. Now the default system is unreliable and may make your website slow as these tasks will run randomly while your visitors are browsing your website. <\/p>\n\n\n\n While setting up a CRON task can be a bit challenging, you will gain a lot in terms of reliability and page load<\/strong> and therefore business.<\/p>\n\n\n\n The first thing you\u2019re going to need to do is disable that default system relying on your site\u2019s traffic to trigger scheduled tasks.<\/p>\n\n\n\n Just edit your wp-config.php at the root of your website, and before the line \u201c\/* That\u2019s all, stop editing! Happy blogging. *\/<\/em>\u201c<\/p>\n\n\n\n Write the following line:<\/p>\n\n\n\n That\u2019s it! It\u2019s disabled, no scheduled tasks will run anymore, which is ok since your system was not working in a reliable way to start with.<\/p>\n\n\n\n Depending on your host, setting up a cron job will be done in a way or another.<\/p>\n\n\n\n If it\u2019s too technical for you you can also create a cron job toward the cron url of your website.<\/p>\n\n\n\n Your WordPress\u2019 site has a page which is dedicated to processing scheduled tasks.<\/p>\n\n\n\n If your site is mysite.com<\/strong>, the cron url will be mysite.com\/wp-cron.php<\/strong> it may be different if your WordPress site is setup in a subfolder for instance mysite.com\/subfolder\/wp-cron.php<\/strong><\/p>\n\n\n\nFor a faster and reliable website<\/h2>\n\n\n\n
Disable WP Cron<\/h2>\n\n\n\n
define('DISABLE_WP_CRON', true);<\/code><\/pre>\n\n\n\n
<\/a>
Setup a real CRON job<\/h2>\n\n\n\n
Setup a simple url CRON job<\/h2>\n\n\n\n