{"id":44424,"date":"2022-01-31T14:22:42","date_gmt":"2022-01-31T14:22:42","guid":{"rendered":"\/tutorials\/?p=44424"},"modified":"2025-12-22T15:25:52","modified_gmt":"2025-12-22T15:25:52","slug":"how-to-setup-and-manage-a-wordpress-cron-job","status":"publish","type":"post","link":"\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","title":{"rendered":"How to set up and manage a WordPress cron job"},"content":{"rendered":"<p>Cron is a UNIX utility that allows users to run scheduled tasks on a web server. WordPress has its own cron system called WP-Cron that simulates the UNIX cron system to automate update checkups, scheduled post publishing, and other repetitive tasks.<\/p><p>If you&rsquo;re a WordPress user, knowing how to schedule WP cron events will make your administrative tasks easier.<\/p><p>This article will cover setting up and managing the WordPress cron system with a plugin and WP-CLI. You will also learn the advantages and disadvantages of using WordPress cron and how it differs from UNIX&rsquo;s cron job.<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Mega-WordPress-Cheat-EN.pdf\" target=\"_blank\" rel=\"noopener\">Download all-in-one WordPress cheat sheet<\/a><\/p><p>\n\n\n<div class=\"protip\">\n                    <h2 class=\"featured-snippet title\">What Is a WordPress Cron Job?<\/h2>\n                    <p>WordPress cron job is a system that simulates the UNIX cron system to automate task scheduling at custom time intervals. It allows WordPress users to perform time-based tasks on page load, such as publishing schedule posts and checking for updates.<\/p>\n                <\/div>\n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-are-the-benefits-and-negatives-of-using-wordpress-cron\">What Are the Benefits and Negatives of Using WordPress Cron<\/h2><p>The WP-Cron system is <strong>easy to set up<\/strong> because, unlike the UNIX cron job, it doesn&rsquo;t require knowledge of UNIX commands. Various WordPress cron job plugins come with features that simplify the setup and management process, making the system accessible even for beginners.<\/p><p>By allowing you to schedule repetitive tasks at a custom time interval, you can save time and focus on other essential tasks. Additionally, this system ensures you don&rsquo;t lose any data if the scheduled tasks fail to run on time &mdash; a feat that the UNIX cron job cannot do.<\/p><p>Unfortunately, WP-Cron only runs when a user visits your website. Low-traffic WordPress sites will skip some jobs if no one triggers a page load, causing a <strong>pending cache buildup<\/strong> and harming the site&rsquo;s load time and performance.<\/p><p><a href=\"\/tutorials\/drive-traffic-to-your-website\">Driving traffic to your site<\/a> won&rsquo;t solve this issue. In fact, high-traffic sites that use cron jobs are prone to <strong>race conditions<\/strong> and <strong>long-running processes<\/strong>. Race conditions happen when multiple visits occur at the same time, triggering WP-Cron to execute the same task simultaneously. This builds up a queue of jobs, resulting in slow performance.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-manage-wordpress-cron-jobs-with-a-plugin\">How to Manage WordPress Cron Jobs With a Plugin<\/h2><p>The easiest way to set up and manage WordPress cron jobs involves using a cron job plugin. In this tutorial, we will use <a href=\"https:\/\/wordpress.org\/plugins\/wp-crontrol\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP Crontrol<\/a> as it&rsquo;s free and has all the necessary features. Feel free to use other plugins that suit your preferences.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-install-the-wp-crontrol-plugin\">1. Install the WP Crontrol Plugin<\/h3><p>First, <a href=\"\/tutorials\/wordpress\/how-to-install-wordpress-plugins\">install and activate the WordPress plugin<\/a> for managing cron jobs by following these steps:<\/p><ol class=\"wp-block-list\">\n<li>Navigate to <strong>Plugins &rarr;<\/strong> <strong>Add New<\/strong> from your WordPress admin dashboard.<\/li>\n\n\n\n<li>Use the filter feature to find <strong>WP Crontrol<\/strong> and click <strong>Install Now<\/strong>.<\/li>\n\n\n\n<li>Once the installation is complete, select <strong>Activate<\/strong>.<\/li>\n<\/ol><p>To see all the cron jobs that are running on your WordPress site, go to <strong>Tools &rarr;<\/strong> <strong>Cron Events<\/strong> from your dashboard.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents.png\"><img decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents.png\/public\" alt=\"The list of existing cron events that currently run on WordPress\" class=\"wp-image-81534\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>\n\n<div><p class=\"important\"><strong>Important!<\/strong> Don&rsquo;t delete any default WordPress cron jobs (they have the <strong>wp<\/strong> prefix). Doing so will disrupt the site&rsquo;s core functionality.<\/p><\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-2-add-a-new-cron-event\">2. Add a New Cron Event<\/h3><p>Now that you can control WordPress cron jobs, you can start managing them. Here&rsquo;s how to add a new cron event:<\/p><ol class=\"wp-block-list\">\n<li>Access the <strong>Cron Events<\/strong> sub-menu and click <strong>Add New<\/strong> at the top of the page.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-addnew-highlighted.png\"><img decoding=\"async\" width=\"1024\" height=\"357\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-addnew-highlighted.png\/public\" alt=\"The Add New button can be found at the top of Cron Event's tab\" class=\"wp-image-81538\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-addnew-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-addnew-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-addnew-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-addnew-highlighted.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"2\" class=\"wp-block-list\">\n<li>Choose the <strong>Standard cron event<\/strong> option and create a <a href=\"\/tutorials\/what-are-wordpress-hooks\/\">WordPress hook<\/a> for the new cron event. Make sure the hook name follows the standard PHP naming convention. Schedule the run time and the recurrence. Feel free to leave the <strong>Arguments <\/strong>textbox empty.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-event.png\"><img decoding=\"async\" width=\"878\" height=\"564\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-event.png\/public\" alt=\"The fields the user needs to fill to create a new cron event\" class=\"wp-image-44437\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-event.png\/w=878,fit=scale-down 878w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-event.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-event.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-event.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 878px) 100vw, 878px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Click <strong>Add Event<\/strong>. The new cron event will appear in the <strong>Cron Events <\/strong>list if the process was successful.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-customcron.png\"><img decoding=\"async\" width=\"1024\" height=\"352\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-customcron.png\/public\" alt=\"The new cron event has appeared in the Cron Events list\" class=\"wp-image-81539\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-customcron.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-customcron.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-customcron.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/wpadmin-tools-cronevents-customcron.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Now that you have a hook, the next step is to add it along with the action that runs when the cron event is triggered. Access your <a href=\"https:\/\/www.hostinger.com\/support\/1583483-comprehensive-guide-to-hpanel-at-hostinger\/\">hPanel<\/a> dashboard and open <strong>File Manager<\/strong> under the <strong>Files <\/strong>section.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-sidebar.png\"><img decoding=\"async\" width=\"448\" height=\"522\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-sidebar.png\/public\" alt=\"The File Manager button on hPanel\" class=\"wp-image-80353\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-sidebar.png\/w=448,fit=scale-down 448w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-sidebar.png\/w=257,fit=scale-down 257w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-sidebar.png\/w=129,fit=scale-down 129w\" sizes=\"(max-width: 448px) 100vw, 448px\" \/><\/a><\/figure><\/div><ol start=\"5\" class=\"wp-block-list\">\n<li>Locate your theme&rsquo;s <strong>functions.php<\/strong> file inside the root directory. Double-click the file to open it and add the following code snippet:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">add_action( 'hostinger_custom_cron', 'hostinger_custom_cron_func' );\nfunction hostinger_custom_cron_func() {\n  wp_mail( 'you@example.com', 'Automatic email', 'Automatic scheduled email from WordPress to test cron');\n}<\/pre><p>This example uses the <strong>wp_mail()<\/strong> function which prompts WordPress to send an email when the cron event runs. Don&rsquo;t forget to change the placeholder with an actual email address.<\/p><ol start=\"6\" class=\"wp-block-list\">\n<li>Save the changes made and load your website. If you receive the test email, the cron event is operating correctly.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/automatic-email.png\"><img decoding=\"async\" width=\"1044\" height=\"314\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/automatic-email.png\/public\" alt=\"The test email that WordPress sent when the new cron event was triggered\" class=\"wp-image-44439\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/automatic-email.png\/w=1044,fit=scale-down 1044w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/automatic-email.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/automatic-email.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/automatic-email.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/automatic-email.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1044px) 100vw, 1044px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-3-set-cron-scheduling\">3. Set Cron Scheduling<\/h3><p>The plugin provides four standard time intervals to choose from, but it still allows users to create custom intervals. Follow these steps to add a new cron schedule:<\/p><ol class=\"wp-block-list\">\n<li>Navigate to <strong>Settings &rarr;<\/strong> <strong>Cron Schedules<\/strong> from your WordPress dashboard.<\/li>\n\n\n\n<li>Fill in the fields under the <strong>Add Cron Schedule<\/strong> section. Here, we will set the interval to 600 seconds (10 minutes). Use the PHP naming convention to create the interval name.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/cron-schedules.png\"><img decoding=\"async\" width=\"423\" height=\"397\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/cron-schedules.png\/public\" alt=\"Cron schedules for setting up a new event using seconds as the interval\" class=\"wp-image-44440\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/cron-schedules.png\/w=423,fit=scale-down 423w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/cron-schedules.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/cron-schedules.png\/w=150,fit=scale-down 150w\" sizes=\"(max-width: 423px) 100vw, 423px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Click <strong>Add Cron Schedule<\/strong>. The new time interval should appear in the list.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-schedule.png\"><img decoding=\"async\" width=\"1202\" height=\"503\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-schedule.png\/public\" alt=\"The Cron Schedules list contains all the available time intervals\" class=\"wp-image-44442\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-schedule.png\/w=1202,fit=scale-down 1202w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-schedule.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-schedule.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-schedule.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/add-cron-schedule.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1202px) 100vw, 1202px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-4-edit-an-existing-cron-event\">4. Edit an Existing Cron Event<\/h3><p>Now that we have a custom interval, let&rsquo;s use it with the custom cron. Here&rsquo;s how to modify an existing cron event:<\/p><ol class=\"wp-block-list\">\n<li>Go back to <strong>Tools <\/strong>&rarr; <strong>Cron Events<\/strong> and locate the cron event we created earlier. Click <strong>Edit <\/strong>below it.<\/li>\n\n\n\n<li>Open the <strong>Recurrence<\/strong> dropdown menu and pick <strong>10 minutes<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/edit-cron-event.png\"><img decoding=\"async\" width=\"891\" height=\"603\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/edit-cron-event.png\/public\" alt=\"Edit Cron Event page, changing the recurrence of an existing cron event\" class=\"wp-image-44443\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/edit-cron-event.png\/w=891,fit=scale-down 891w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/edit-cron-event.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/edit-cron-event.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/01\/edit-cron-event.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 891px) 100vw, 891px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Click <strong>Update Event<\/strong>.<\/li>\n<\/ol><h2 class=\"wp-block-heading\" id=\"h-how-to-set-up-wordpress-cron-jobs-with-wp-cli\">How to Set Up WordPress Cron Jobs with WP-CLI<\/h2><p>Another way to set up WordPress cron jobs involves using <a href=\"\/tutorials\/wp-cli\">WP-CLI<\/a>. This tool lets you manage the site via a command-line interface.<\/p><p>Hostinger&rsquo;s <a href=\"\/wordpress-hosting\">Managed WordPress Hosting plans<\/a> come with WP-CLI pre-installed. Therefore, you&rsquo;ll only need to connect to your hosting account <a href=\"\/tutorials\/how-to-use-putty-ssh\">using Putty SSH<\/a>.<\/p><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-wordpress-hosting\" href=\"\/wordpress-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"2048\" height=\"600\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/public\" alt=\"\" class=\"wp-image-111781\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><p>To access the existing cron events, enter this command in the terminal:<\/p><pre class=\"wp-block-preformatted\">wp cron event list<\/pre><p>The following command will display the other commands you can use with WP-CLI:<\/p><pre class=\"wp-block-preformatted\">wp help<\/pre><h2 class=\"wp-block-heading\" id=\"h-how-to-create-a-real-cron-job\">How to Create a Real Cron Job<\/h2><p>WordPress creates and stores the WP-Cron script inside the <strong>wp-cron.php<\/strong> file. While it allows your WordPress website to have cron jobs running regardless of the OS, this file isn&rsquo;t immune to attacks and may conflict with caching plugins. The use of real <a href=\"\/tutorials\/cron-job\">cron jobs<\/a> can eliminate the constant file execution.<\/p><p>Before setting up real cron jobs, you&rsquo;ll need to disable the default WordPress cron. To disable WP_CRON, add this code snippet to the <a href=\"\/tutorials\/wp-config-php\">wp-config.php<\/a> file above the &ldquo;<em>\/* That&rsquo;s all, stop editing! Happy blogging. *\/<\/em>&rdquo; line:<\/p><pre class=\"wp-block-preformatted\">define( 'DISABLE_WP_CRON', true );<\/pre><p>The next step is to set up a real cron job to schedule WordPress core tasks. The process may vary depending on your hosting provider or service. If you&rsquo;re a Hostinger user, follow this tutorial:<\/p><ol class=\"wp-block-list\">\n<li>Access your hPanel dashboard and navigate to <strong>Cron Jobs<\/strong> under the <strong>Advanced <\/strong>section.<\/li>\n\n\n\n<li>Add this code snippet to the <strong>Command to run<\/strong> textbox:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">wget -O \/dev\/null -o \/dev\/null https:\/\/yoursite.com\/wp-cron.php?doing_wp_cron<\/pre><p>Don&rsquo;t forget to change the placeholder with your website&rsquo;s actual URL.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/10\/cronjob.png\"><img decoding=\"async\" width=\"1654\" height=\"864\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/10\/cronjob.png\/public\" alt=\"Cron Jobs section on hPanel \" class=\"wp-image-65596\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/10\/cronjob.png\/w=1654,fit=scale-down 1654w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/10\/cronjob.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/10\/cronjob.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/10\/cronjob.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/10\/cronjob.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1654px) 100vw, 1654px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>hPanel provides the most common interval options to choose from. We recommend starting with <strong>twice an hour<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Save <\/strong>to store the new cron job settings.<\/li>\n<\/ol><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>The WordPress cron job makes it convenient to schedule tasks at custom time intervals. While WP-Cron has some disadvantages, knowing how to use this utility will allow you to perform administrative tasks more efficiently.<\/p><p>We hope this article has helped you understand the functionality of the WordPress cron job and how to set it up using a plugin and WP-CLI. Good luck.<\/p><p>If you&rsquo;re looking to optimize your WordPress site&rsquo;s performance even further, we recommend using high-quality WordPress hosting.    <\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Learn Other Expert WordPress Techniques<\/h4>\n                    <p><a href=\"\/tutorials\/how-to-create-custom-widget-in-wordpress\">How to Create WordPress Custom Widgets<\/a><br>\n<a href=\"\/tutorials\/how-to-become-wordpress-developer\">How to Become a WordPress Developer<\/a><br>\n<a href=\"\/tutorials\/wordpress-page-template\">Guide to WordPress Page Template<\/a><br>\n<a href=\"\/tutorials\/wordpress-custom-post-types\">How to Create a WordPress Custom Post Type<\/a><br>\n<a href=\"\/tutorials\/wordpress-template-hierarchy\">WordPress Template Hierarchy Guide<\/a><\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-set-up-a-wordpress-cron-job-faq\">How to Set Up a WordPress Cron Job FAQ<\/h2><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1643636029505\"><h3 class=\"schema-faq-question\">What Is the Difference Between WP-Cron and Cron?<\/h3> <p class=\"schema-faq-answer\">WP-Cron is a web-based system that simulates the UNIX cron system. WP-Cron events are triggered on page load whereas the real cron runs every minute.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1643636051716\"><h3 class=\"schema-faq-question\">Should I Use the Real Cron or WP-Cron?<\/h3> <p class=\"schema-faq-answer\">WP-Cron works perfectly for its purpose, which is to run WordPress core tasks. However, using it for executing additional tasks can harm your site&rsquo;s load speed. For this reason, we recommend using real cron jobs for better performance.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1643636075938\"><h3 class=\"schema-faq-question\">How Do I Stop a Cron Job in WordPress?<\/h3> <p class=\"schema-faq-answer\">If you have unused cron jobs, the easiest solution would be to delete them. Alternatively, modify the time interval as needed.<br><br>Run this command to delete cron jobs that use a specific hook. This method is ideal for removing obsolete cron jobs.<br><br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">$ wp cron event delete hook_name<\/code><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1677598552714\"><h3 class=\"schema-faq-question\">Where Can I Find Cron Jobs in WordPress?<\/h3> <p class=\"schema-faq-answer\">Cron jobs in WordPress can be found in the <strong>wp-config.php<\/strong> file or by using a plugin such as <strong>WP Crontrol<\/strong> or <strong>Advanced Cron Manager<\/strong>.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1677598597513\"><h3 class=\"schema-faq-question\">How Do I Run a Cron Job in WordPress?<\/h3> <p class=\"schema-faq-answer\">To run a cron job in WordPress, you can use the <strong>wp_schedule_event() <\/strong>function in your theme&rsquo;s <strong>functions.php<\/strong> file or use a plugin such as <strong>WP Crontrol <\/strong>or <strong>Advanced Cron Manager<\/strong> to set up and manage cron jobs.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Cron is a UNIX utility that allows users to run scheduled tasks on a web server. WordPress has its own [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":115,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"3 Confirmed Ways to Set Up a WordPress Cron Job","rank_math_description":"Using a WordPress cron job is an easy way to automate your website tasks \u2013 check out this guide for 3 methods to manage it!","rank_math_focus_keyword":"wordpress cron job","footnotes":""},"categories":[22643,22637],"tags":[],"class_list":["post-44424","post","type-post","status-publish","format-standard","hentry","category-advanced","category-wordpress"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/cron-job-wordpress","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-configurar-wordpress-cron-job","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/como-configurar-wordpress-cron-job","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/como-configurar-wordpress-cron-job","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-configurar-wordpress-cron-job","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/cron-job-wordpress","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/44424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/115"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=44424"}],"version-history":[{"count":46,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/44424\/revisions"}],"predecessor-version":[{"id":138388,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/44424\/revisions\/138388"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=44424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=44424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=44424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}