{"id":478,"date":"2023-04-14T10:58:59","date_gmt":"2023-04-14T10:58:59","guid":{"rendered":"https:\/\/help.kybernaut.cz\/?post_type=ht_kb&#038;p=478"},"modified":"2023-04-14T10:58:59","modified_gmt":"2023-04-14T10:58:59","slug":"how-to-use-the-server-cron-instead-of-wp-cron","status":"publish","type":"ht_kb","link":"https:\/\/help.kybernaut.cz\/en\/help\/how-to-use-the-server-cron-instead-of-wp-cron\/","title":{"rendered":"How to use the server cron instead of WP cron"},"content":{"rendered":"\n<p>Here&#8217;s a guide on how to use your server&#8217;s cron instead of WordPress&#8217; built-in cron feature.<\/p>\n\n\n\n<p>First, let&#8217;s understand the difference between the two:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>WordPress cron is a feature that allows you to schedule tasks to run at specific intervals. However, it relies on user traffic to trigger these tasks, which can be unreliable if your site doesn&#8217;t receive consistent traffic.<\/li>\n\n\n\n<li>Server cron is a system-level tool that can run tasks at specific intervals, regardless of whether your site receives traffic or not.<\/li>\n<\/ul>\n\n\n\n<p>Here&#8217;s how you can switch from WordPress&#8217; cron to your server&#8217;s cron:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Disable WordPress cron<\/h2>\n\n\n\n<p>To disable WordPress cron, open your site&#8217;s\u00a0<code>wp-config.php<\/code>\u00a0file and add the following line of code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define('DISABLE_WP_CRON', true);<\/code><\/pre>\n\n\n\n<p>This will prevent WordPress from running its cron tasks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Set up server cron<\/h2>\n\n\n\n<p>Next, you&#8217;ll need to set up a cron job on your server to run the tasks that WordPress was handling. The exact process for setting up a cron job will depend on your hosting provider, but here&#8217;s a general overview:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Access your server&#8217;s control panel or SSH into your server.<\/li>\n\n\n\n<li>Locate the &#8220;Cron Jobs&#8221; section.<\/li>\n\n\n\n<li>Add a new cron job with URL pointing to your wp-cron.php file:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;www.yoursite.com\/wp-cron.php?doing_wp_cron<\/code><\/pre>\n\n\n\n<p>Replace\u00a0<code>https:\/\/www.yoursite.com<\/code>\u00a0with your site&#8217;s URL.<\/p>\n\n\n\n<p>This command will trigger WordPress&#8217; cron tasks at the specified intervals.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Test and monitor<\/h2>\n\n\n\n<p>After setting up your server cron, it&#8217;s important to test and monitor it to ensure that the tasks are running as expected. Here are some things to keep in mind:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check your site&#8217;s error logs for any issues related to cron.<\/li>\n\n\n\n<li>Monitor your site&#8217;s performance to ensure that the cron tasks aren&#8217;t causing any slowdowns.<\/li>\n\n\n\n<li>Test the cron job by scheduling a task to run at a specific time and verifying that it runs as expected.<\/li>\n<\/ul>\n\n\n\n<p>That&#8217;s it! By using your server&#8217;s cron instead of WordPress&#8217; cron, you can ensure that your scheduled tasks run reliably and without relying on user traffic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a guide on how to use your server&#8217;s cron instead of WordPress&#8217; built-in cron feature. First, let&#8217;s understand the difference between the two: Here&#8217;s how you can switch from WordPress&#8217; cron to your server&#8217;s cron: 1. Disable WordPress cron To disable WordPress cron, open your site&#8217;s\u00a0wp-config.php\u00a0file and add the&#8230;<\/p>\n","protected":false},"author":1,"template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[80],"ht-kb-tag":[],"class_list":["post-478","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-general"],"_links":{"self":[{"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/ht-kb\/478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/ht-kb\/478\/revisions"}],"predecessor-version":[{"id":479,"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/ht-kb\/478\/revisions\/479"}],"wp:attachment":[{"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/media?parent=478"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/ht-kb-category?post=478"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/help.kybernaut.cz\/en\/wp-json\/wp\/v2\/ht-kb-tag?post=478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}