{"id":13899,"date":"2020-10-07T17:00:24","date_gmt":"2020-10-07T15:00:24","guid":{"rendered":"https:\/\/qodeinteractive.com\/magazine\/?p=13899"},"modified":"2021-01-25T00:00:27","modified_gmt":"2021-01-24T23:00:27","slug":"wordpress-cron-job","status":"publish","type":"post","link":"https:\/\/qodeinteractive.com\/magazine\/wordpress-cron-job\/","title":{"rendered":"What Is a WordPress Cron Job and How to Use It"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]Scheduling events in WordPress is as equally valuable as in real life. For example, specifying a date and time when a post is to be published while you are away is just one of many examples of the importance of scheduling. With WordPress sites, scheduling is managed with the help of WordPress Cron jobs.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In this article, we\u2019ll dig deeper into the subject of WordPress Cron jobs and Cron jobs in general to answer the following questions:<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#what-is-a-wordpress-cron-job\">What is a WordPress Cron job<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#keep-track-of-a-wordpress-cron-job\">How to keep track of a WordPress Cron job<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#manage-a-wordpress-cron-job\">How to manage a WordPress Cron job<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#deactivate-the-wp-cron-system\">How to deactivate the WP-Cron system<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"what-is-a-wordpress-cron-job\"><\/a>What is a WordPress Cron job<\/h2>\n<p>[\/vc_column_text][vc_column_text]Cron, or the system Cron, is a Linux and Unix-like utility system. It is typically used for scheduling and performing scheduled tasks on a server. These tasks run in the background at a specific date, time, and time interval. Each task is referred to as a Cron job and, in most cases, they are maintenance-related. Automating these tasks will save you a great deal of time.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]WordPress uses a system called <a href=\"https:\/\/developer.wordpress.org\/plugins\/cron\/scheduling-wp-cron-events\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-Cron<\/a>. The tasks it tackles include checking for updates, deleting the comments from the trash, scheduling posts to be published, or performing a predefined website backup using a backup plugin, and more. However, WP-Cron is somewhat unreliable because it\u2019s run only when a page (either frontend or backend) loads. This could be a problem if you have a period with a low amount of site traffic, as it might leave some scheduled tasks unexecuted. We will explore this in more depth in the section on deactivating the WP-Cron system.[\/vc_column_text][vc_empty_space height=&#8221;80px&#8221;][vc_widget_sidebar sidebar_id=&#8221;new-top-picks-banner&#8221;][vc_empty_space height=&#8221;81px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"keep-track-of-a-wordpress-cron-job\"><\/a>How to keep track of a WordPress Cron job<\/h2>\n<p>[\/vc_column_text][vc_column_text]The easiest way to manage your WP-Cron jobs is by using an appropriate WordPress plugin. The one that we used for this article and found very handy is <a href=\"https:\/\/wordpress.org\/plugins\/wp-crontrol\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP Crontrol<\/a>. After <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-install-a-wordpress-plugin\/\">installing the plugin<\/a>, <strong>navigate to Tools &gt; Cron Events<\/strong>, to see all currently scheduled Cron jobs (or Cron events), sorted into a list.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events.jpg\" class=\"attachment-full size-full\" alt=\"Cron Events\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The list contains all the Cron-relevant data: <a href=\"https:\/\/developer.wordpress.org\/plugins\/hooks\/\" target=\"_blank\" rel=\"noopener noreferrer\">the hook<\/a> and action name used to create a WordPress Cron job, its arguments displayed in a JSON encoded array, and the recurrence and time of the next Cron job run. Hovering over a single row within this list gives us additional options. So you can <strong>edit, run, or delete a Cron event<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Before we proceed to show you the process for managing Cron events, we\u2019re going to share a few tips about appropriate hook names. Hook names are written lowercase and, in case of multiple words, separated by an underscore. Also, the names should be clear and concise so that you can tell the hook\u2019s purpose at first glance. Finally, we strongly advise that you create hook names with a unique prefix. This practice prevents the code of other plugins or themes from overriding them unintentionally. If you take a look at the list of hook names in the image above, you can see several different prefixes. The \u201c<strong>wp_<\/strong>\u201d prefix denotes default WordPress Cron jobs and \u201c<strong>woocommerce_<\/strong>\u201d marks the Cron jobs belonging to the WooCommerce plugin. Likewise, we use the \u201c<strong>qode_<\/strong>\u201d prefix to distinguish our custom WordPress Cron job that we\u2019re using as an example for this article.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Now let\u2019s take a look at how to add, edit, or delete a Cron event in WordPress.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"manage-a-wordpress-cron-job\"><\/a>How to manage a WordPress Cron job<\/h2>\n<p>[\/vc_column_text][vc_column_text]In this section, we will explain how you can add, edit, and delete WordPress Cron jobs using the WP Crontrol plugin. Also, we will describe how to add custom time intervals for added flexibility. However, as you will have to edit the functions.php file in the process of making a WordPress Cron job, we strongly suggest <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-manually-backup-wordpress-website\/\">making a backup of your WordPress website<\/a> beforehand.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\">How to add a WordPress Cron job<\/h3>\n<p>[\/vc_column_text][vc_column_text]To add a new WordPress Cron job, <strong>navigate to Tools &gt; Cron Events<\/strong> and <strong>click on the <em>Add Cron Event<\/em> tab<\/strong>. <strong>Insert a hook name and choose a recurrence period<\/strong> (whether an event will be repeating or not). If you choose to have a recurring event, the options for the recurrence period are: every minute, every five minutes, hourly, twice daily, daily, weekly, every 15 days, and monthly. We will also discuss how you can add your custom recurrence period.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>As for the other options, you can add a JSON encoded array of arguments and schedule when the next run of the Cron event will be<\/strong>. After you\u2019ve filled all the options, <strong>press the <em>Add Event<\/em> button<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"388\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-2.jpg\" class=\"attachment-full size-full\" alt=\"Cron Events\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-2.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-2-300x166.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-2-620x344.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>This will create the WP Cron job, so next, you need to add the appropriate code telling it what to do<\/strong>. <strong>You need to insert that code at the bottom of your functions.php file<\/strong>. In general, the code that you need to add is relatively straightforward and can be summarized by a pseudocode snippet given below.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">function name_of_the_callback_function() {\r\n\/\/ some code here\r\n}\r\nadd_action( 'name_of_the_cron_job_hook', 'name_of_the_callback_function' );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Now that we introduced the steps involved, we can take a look at them in detail. Alongside them, we will examine the code we used for our example Cron job.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]First,<strong> connect to your server using your FTP credentials and navigate to your root WordPress directory<\/strong>, often called public_html.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Public-HTML.jpg\" class=\"attachment-full size-full\" alt=\"FTP Public HTML\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Public-HTML.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Public-HTML-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Public-HTML-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Then, <strong>navigate to the<em> \/wp-content\/themes<\/em> directory and click on the folder of the theme you are currently using<\/strong> to open it.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-WP-Content-Themes.jpg\" class=\"attachment-full size-full\" alt=\"FTP WP Content Themes\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-WP-Content-Themes.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-WP-Content-Themes-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-WP-Content-Themes-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Once there,<strong> locate the functions.php file, right-click on it,<\/strong> and <strong>press the <em>View\/Edit<\/em> option<\/strong> from the menu that appears.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"500\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Functions-1.jpg\" class=\"attachment-full size-full\" alt=\"FTP Functions\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Functions-1.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Functions-1-300x214.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Functions-1-620x443.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>Open the file using your preferred text editor and scroll to its bottom<\/strong>. There, you should <strong>insert the code<\/strong> we have included below.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">function qode_custom_cron_mail() {\r\nwp_mail( 'your@email.com', 'Testing a cron event', 'This is an automatic WordPress email for testing a cron event.');\r\n}\r\nadd_action( 'qode_custom_cron', 'qode_custom_cron_mail' );<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Code-1.jpg\" class=\"attachment-full size-full\" alt=\"FTP Code\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Code-1.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Code-1-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Code-1-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>Make sure to use an actual email address you have access to instead of your@email.com, so that you can properly test the Cron event<\/strong>. Afterward,<strong> save the changes you made<\/strong> and <strong>upload the file back to the server<\/strong>, thus overriding the existing one.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]We will briefly cover the code used above.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Thanks to the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/add_action\/\" target=\"_blank\" rel=\"noopener noreferrer\">add_action()<\/a> function we can assign which function is executed when a specific hook is triggered. We made sure that the first argument of that function is the same hook name as the WordPress Cron job we created earlier. And the second argument is the qode_custom_cron_mail() function which we also defined. That function simply sends an email using the default WordPress mailing function wp_mail().[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Therefore, when our custom Cron job is triggered, an email is sent to your@email.com. That email will have the title<em> Testing a cron event<\/em> and its content will be <em>This is an automatic WordPress email for testing a cron event<\/em>.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To verify this, <strong>you only need to check the inbox folder of the email you used. If you aren\u2019t able to find the email, make sure to check the spam and trash folders as well<\/strong>. After finding the email, the testing process is over.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Cron-Event-Result.jpg\" class=\"attachment-full size-full\" alt=\"Adding a Cron Event Result\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Cron-Event-Result.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Cron-Event-Result-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Cron-Event-Result-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;82px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\">How to edit a WordPress Cron job<\/h3>\n<p>[\/vc_column_text][vc_column_text]In this section, we will discuss how you can edit a scheduled WordPress Cron job. However, if you are editing a plugin-specific Cron job, you should contact its authors and check the plugin documentation first. Some plugins depend on Cron jobs to run smoothly, so checking before making any changes will help you avoid unforeseen website issues.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To edit an existing WordPress Cron event, you should <strong>navigate to Tools &gt; Cron Events. Locate the Cron event you wish to edit, hover over it and press the<em> Edit<\/em> option to edit it.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Edit.jpg\" class=\"attachment-full size-full\" alt=\"Cron Events Edit\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Edit.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Edit-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Edit-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]<strong>Change the parameters to suit your needs and press the <em>Update Event<\/em> button when you\u2019re done<\/strong>. For our example, we only changed the time occurrence from every five minutes to non-repeating, but you can change all the parameters if you need to.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"400\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Edit-2.jpg\" class=\"attachment-full size-full\" alt=\"Cron Events Edit\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Edit-2.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Edit-2-300x171.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Edit-2-620x354.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Sometimes, you might want to be more flexible and set a different recurrence period than the default ones offered by WP Crontrol. Fortunately, this plugin includes the option of adding a custom period. Let\u2019s examine how to do so.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To add a custom time scheduling period, <strong>navigate to Settings &gt; Cron Schedules<\/strong> and <strong>scroll to the bottom of the page<\/strong>. <strong>Within the <em>Add Cron Schedule<\/em> subsection, insert the information about the internal name, the time interval, and which name to display<\/strong>. After you insert this information, <strong>press the <em>Add Cron Schedule<\/em><\/strong> <strong>button<\/strong> below.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Time-Period.jpg\" class=\"attachment-full size-full\" alt=\"Adding a Time Period\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Time-Period.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Time-Period-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Time-Period-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]This creates a new custom period that you can use when adding a new WordPress Cron job or while editing an existing one.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"418\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Time-Period-2.jpg\" class=\"attachment-full size-full\" alt=\"Adding a Time Period\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Time-Period-2.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Time-Period-2-300x179.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Adding-a-Time-Period-2-620x370.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;82px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\">How to delete a WordPress Cron job<\/h3>\n<p>[\/vc_column_text][vc_column_text]In this section, we will show how to delete a WordPress Cron job. First, <strong>we must warn you not to delete any default WordPress Cron jobs\u2014those with the prefix \u201cwp_\u201d. Removing one of them may cause issues with basic WordPress functionalities.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]With that being said, to delete a WP-Cron event you need to <strong>navigate to Tools &gt; Cron Events.<\/strong> <strong>Locate the Cron event you wish to delete<\/strong>, and <strong>hover over it<\/strong>. <strong>Consider once more if you wish to delete the event, as there won\u2019t be a confirmation button before it\u2019s removed<\/strong>. Once you are sure that you want to delete the Cron event, <strong>press the <em>Delete<\/em> option<\/strong> next to it.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"448\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Delete.jpg\" class=\"attachment-full size-full\" alt=\"Cron Events Delete\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Delete.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Delete-300x192.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Delete-620x397.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]This will immediately delete the WordPress Cron event, and you will see a confirmation message, as shown in the image below.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Delete-2.jpg\" class=\"attachment-full size-full\" alt=\"Cron Events Delete\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Delete-2.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Delete-2-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Events-Delete-2-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Afterward, <strong>you will have to access the functions.php file via FTP<\/strong> and <strong>delete or comment out the code<\/strong> that \u201ctold\u201d the Cron job what to do. You can follow the same steps for <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-use-ftp\/\">using FTP<\/a> that you used to add the code earlier.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\"><a id=\"deactivate-the-wp-cron-system\"><\/a>How to deactivate the WP-Cron system<\/h2>\n<p>[\/vc_column_text][vc_column_text]While WP-Cron gives you the ability to schedule events, the fact that they can be executed only after someone visits your website can cause a certain set of issues. Websites with a lower traffic rate could have their scheduled events skipped because of it. However, websites with higher traffic rates aren\u2019t exempt from issues, either. For example, if your website has numerous simultaneous visits, multiple instances of the same WP-Cron jobs could be needlessly running at the same time. And, as popular and high traffic websites tend to have a high amount of plugins installed, it can take a toll on your server resources and your website speed.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Therefore, you might want to deactivate WP-Cron and use the system Cron instead. We will show you the steps for working with the scheduling process in the sections below. Keep in mind, those steps can vary depending on your hosting and require you to understand Linux commands. Because of that, we strongly suggest asking your hosting provider to do it on your behalf. With that being said, we can proceed to the actual steps.<br \/>\n[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]First, <strong>connect to your server using your FTP credentials<\/strong> and <strong>navigate to your root WordPress directory<\/strong>, often called public_html.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Public-HTML.jpg\" class=\"attachment-full size-full\" alt=\"FTP Public HTML\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Public-HTML.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Public-HTML-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/FTP-Public-HTML-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Within it, <strong>find the wp-config.php file, right-click on it<\/strong>, and <strong>press the <em>View\/Edit<\/em> optio<\/strong>n.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"600\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/WP-Config.jpg\" class=\"attachment-full size-full\" alt=\"WP Config\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/WP-Config.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/WP-Config-300x257.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/WP-Config-620x531.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Then <strong>open the file in the text editor of your choice<\/strong> and <strong>insert the following line of code<\/strong>:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define('DISABLE_WP_CRON', true);<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>It should be placed directly above the \/* That\u2019s all, stop editing! Happy publishing. *\/ line of code.<\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/WP-Config-Code.jpg\" class=\"attachment-full size-full\" alt=\"WP Config Code\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/WP-Config-Code.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/WP-Config-Code-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/WP-Config-Code-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]This will disable WP-Cron from running automatically on every page load. Instead, we can program it to run directly by <strong>making a web-request to our wp-cron.php file<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To do so, <strong>log in to cPanel using your cPanel credentials and scroll down. Locate the <em>Cron Jobs<\/em> option<\/strong> within the <em>Advanced<\/em> section and <strong>click on it<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Jobs-in-cPanel.jpg\" class=\"attachment-full size-full\" alt=\"Cron Jobs in cPanel\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Jobs-in-cPanel.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Jobs-in-cPanel-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Jobs-in-cPanel-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]In the window that opens, <strong>scroll down a bit to the <em>Add New Cron Job<\/em> section<\/strong>. <strong>Choose the recurrence period from the list of <em>Common Settings<\/em><\/strong> and <strong>insert the following in the <em>Command<\/em> field<\/strong>:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]wget -q -O &#8211; https:\/\/your-website-url.com\/wp-cron.php?doing_wp_cron &gt;\/dev\/null 2&gt;&amp;1[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Make sure to use your actual website URL instead of the <em>https:\/\/your-website-url.com<\/em> placeholder.<\/strong> When you\u2019re done, <strong>press the <em>Add New Cron Job<\/em> button<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"474\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Jobs-in-cPanel-2.jpg\" class=\"attachment-full size-full\" alt=\"Cron Jobs in cPanel\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Jobs-in-cPanel-2.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Jobs-in-cPanel-2-300x203.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/10\/Cron-Jobs-in-cPanel-2-620x420.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The command we used relies on the GNU Wget utility. As this is quite an advanced subject that requires further study we suggest you review <a href=\"https:\/\/www.gnu.org\/software\/wget\/manual\/html_node\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">the Wget manual<\/a>, to learn about all the available commands.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Regarding the command we used, the<em> &gt;\/dev\/null 2&gt;&amp;1<\/em> part at the end can be omitted. It only serves to disable email notifications regarding the scheduled Cron job, so you can opt to leave it out.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Final thoughts<\/h2>\n<p>[\/vc_column_text][vc_column_text]Being able to automate and schedule certain tasks related to your website can be immensely helpful. Using a WordPress Cron job, you can be sure that you won\u2019t forget to run a routine task or that you won\u2019t run late with one. Moreover, they will save you time so you can dedicate it to developing your site, using <a href=\"https:\/\/qodeinteractive.com\/magazine\/free-seo-tools\/\">tools to optimize your SEO<\/a>, or simply sitting back and relaxing. We hope this article showed you that there\u2019s no great mystery to Cron jobs and that they are relatively easy to manage. So you can get back to more demanding tasks and leave the simple stuff for Cron to handle.[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Learning to make and use a WordPress Cron job will give you access to an amazing tool for task automation and scheduling for your site.<\/p>\n","protected":false},"author":11229,"featured_media":13942,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14,4,13],"class_list":["post-13899","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-core","tag-tips","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/13899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/users\/11229"}],"replies":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/comments?post=13899"}],"version-history":[{"count":0,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/13899\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media\/13942"}],"wp:attachment":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media?parent=13899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/categories?post=13899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/tags?post=13899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}