{"id":11702,"date":"2023-11-30T14:17:59","date_gmt":"2023-11-30T14:17:59","guid":{"rendered":"https:\/\/www.20i.com\/blog\/?p=11702"},"modified":"2025-01-15T16:07:11","modified_gmt":"2025-01-15T16:07:11","slug":"how-to-use-wordpress-cron-jobs","status":"publish","type":"post","link":"https:\/\/www.20i.com\/blog\/how-to-use-wordpress-cron-jobs\/","title":{"rendered":"How to Use WordPress Cron Jobs"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">WordPress Cron jobs are a scheduling system that allows you to automate various tasks within WordPress. Although they\u2019re not the true UNIX cron jobs, you still achieve the same outcome.&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using WP Cron to automate routine and time-consuming tasks and can save a lot of manual work.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Automated tasks are processed in the background, so it\u2019s essential to ensure that scheduled task system is configured correctly to avoid issues with your website&#8217;s functionality.&nbsp;&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What are WordPress cron jobs?<\/strong>&nbsp;<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The key difference between WP Cron and the traditional UNIX Cron is that when scheduled tasks are executed with WP Cron, this takes place within the WordPress website. Whereas traditional UNIX scheduled tasks are executed within the server environment.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The advantage of traditional Unix Cron is that WP Cron is only executed if a user visits your website. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unix Cron uses the system\u2019s clock, so you can schedule a time or how often a scheduled task is executed even if there are not any visits to your website.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nevertheless, setting up a scheduled task with WP Cron is relatively easy and doesn\u2019t require knowledge of UNIX to configure a command to execute.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Some use cases of WP Cron include:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Import new products to your website&nbsp;<\/li>\n\n\n\n<li>Automate publishing of posts&nbsp;<\/li>\n\n\n\n<li>Send out email notifications for your subscribers or customers&nbsp;<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Setting up and managing WordPress Cron jobs with a plugin<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are various ways to setup and manage WordPress cron jobs. In the following example, I\u2019ll use a WordPress plugin called <a href=\"https:\/\/wordpress.org\/plugins\/wp-crontrol\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP Control<\/a>, which will allow you to view and configure WordPress crons.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With WP Control, you can:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>View all cron events, their arguments, when they\u2019re next due to run, the action the event will take and how often the event will run.&nbsp;&nbsp;<\/li>\n\n\n\n<li>Add, Edit, delete, pause, resume, and immediately run cron events.&nbsp;<\/li>\n\n\n\n<li>Add and remove custom cron schedules.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For this example, \u2019ll use WP Control to create a custom event using wp_mail.&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"1\">\n<li><strong>Install WP Control: <\/strong>You can use the usual method of installing the plugin via wp-admin and then activate it.<br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"166\" class=\"wp-image-11724\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/WP-Control-install.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/WP-Control-install.png 1723w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-install-300x83.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-install-768x213.png.webp 768w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-install-1536x426.png.webp 1536w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-install-370x103.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-install-270x75.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-install-570x158.png.webp 570w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-install-740x205.png.webp 740w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-install-150x42.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br><\/li>\n\n\n\n<li><strong>View Cron Events: <\/strong>When the installation has completed, head over to \u2018Cron Events\u2019 under the \u2018Tools\u2019 section. This is where you can view and manage your current cron events. The event names should be recognisable as they would reference part of your plugin name such as \u201cai1wm_storage_cleanup\u201d<br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"95\" class=\"wp-image-11723\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/WP-control-events.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/WP-control-events.png 1708w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-control-events-300x48.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-control-events-768x122.png.webp 768w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-control-events-1536x244.png.webp 1536w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-control-events-370x59.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-control-events-270x43.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-control-events-570x90.png.webp 570w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-control-events-740x117.png.webp 740w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-control-events-150x24.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br><\/li>\n\n\n\n<li><strong>Head over to Appearance &gt; Theme File Editor &gt; Functions.php <\/strong>This is where you will edit the Functions.php file and add the coding for the custom cron event. The following example will send an email using the wp_mail function when the cron has triggered.&nbsp;<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action( '20i_demo_cron', 'demo_function' ); \n\nfunction demo_function() { \n\nwp_mail( 'sales@20i-demo.com, '20i Demo Cron', 'Hosted By 20i!' ); \n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a breakdown of the above code snippet:&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>add_action( '20i_demo_cron', 'demo_function' );&nbsp;<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This line of code is adding an action hook in WordPress. In this case, we\u2019re creating a custom action hook named &#8217;20i_demo_cron&#8217; and this is what will be used when adding the cron event using WP Control.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>function demo_function()&nbsp;&nbsp;<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This code defines a custom PHP function called demo_function. This will be called when &#8217;20i_demo_cron&#8217; is triggered.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>{&nbsp;<\/code>\n<code>wp_mail( 'sales@20i-demo.com, '20i Demo Cron', 'Hosted By 20i!' );<\/code>\n<code>}<\/code>&nbsp;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inside <code>demo_function<\/code> , we\u2019re using the built in WordPress function<code> wp_mail<\/code> to send an email to <a href=\"mailto:sales@20i-demo.com\" target=\"_blank\" rel=\"noreferrer noopener\">sales@20i-demo.com<\/a> with the subject heading \u201820i Demo Cron\u2019 and a message body of \u2018Hosted By 20i!\u2019&nbsp;&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li><strong>From \u2018Cron Events\u2019 > Click Add New: <\/strong>From here, you can create your new cron event. In the following example, I created an event name called \u201820i_demo_cron\u2019, scheduled this to run immediately and to recur daily. \u00a0<br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"377\" class=\"wp-image-11722\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/WP-Control-create-event.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/WP-Control-create-event.png 857w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-create-event-300x188.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-create-event-768x482.png.webp 768w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-create-event-370x232.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-create-event-270x169.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-create-event-570x358.png.webp 570w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-create-event-740x465.png.webp 740w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/WP-Control-create-event-150x94.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br><\/li>\n\n\n\n<li>After clicking \u2018Add Event\u2019 this should trigger the event and if you check your inbox, you should have received the email from WordPress with the subject heading \u201820i Demo Cron\u2019 and message \u2018Hosted By 20i!\u2019\u00a0<br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"354\" class=\"wp-image-11720\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/message-received.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/message-received.png 319w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/message-received-300x177.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/message-received-270x159.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/message-received-150x88.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Setting Up and Managing Basic WordPress Cron Jobs using WP-CLI<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">WP-CLI stands for WordPress Command Line Interface. It provides a way to manage your WordPress installation via command line rather than through the WordPress admin area. This is available on our hosting via SSH.&nbsp;&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"1\">\n<li>Access your hosting via SSH. If you\u2019re a 20i customer, you can access your hosting via SSH by <a href=\"https:\/\/docs.20i.com\/reseller-hosting\/connect-via-ssh\" target=\"_blank\" rel=\"noreferrer noopener\">following this guide<\/a>&nbsp;<br>&nbsp;<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>When you\u2019ve accessed your hosting over SSH, you will need to go into your WordPress installation using the \u2018cd\u2019 (change directory) command. In the following example, the WordPress install is in the public_html directory so I just need to run the following command:&nbsp;<br>&nbsp;<br><code>cd public_html&nbsp;<br><\/code>&nbsp;<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Now that you\u2019re in the WordPress installation directory, you can now use WP-CLI to manage your cron events. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some examples of commands you can use to manage your cron events&#8230;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>List Cron Events<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can use the wp cron event list command to list all scheduled cron events on your WordPress site. After running the command, you will see four columns, Hook, next run time, countdown to next run time and recurrence.\u00a0<br><br><code>wp cron event list\u00a0<\/code><br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"197\" class=\"wp-image-11728\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wpcronlist.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wpcronlist.png 1201w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronlist-300x99.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronlist-768x253.png.webp 768w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronlist-370x122.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronlist-270x89.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronlist-570x187.png.webp 570w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronlist-740x243.png.webp 740w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronlist-150x49.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Run a Specific Cron Event<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can manually trigger a specific cron event to run using the wp cron event run command. Replace event-name with the name of the event you want to execute.\u00a0<br><br><code>wp cron event run event-name\u00a0<\/code><br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"73\" class=\"wp-image-11729\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wpcronrun.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wpcronrun.png 548w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronrun-300x37.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronrun-370x45.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronrun-270x33.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcronrun-150x18.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Schedule\/Create a new Cron Event<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can create a new recurring Cron Event using wp-cli. The following command will create a new cron event to run immediately and reoccur daily. \u00a0<br>\u00a0<br><code>wp cron event schedule cron_event now daily\u00a0<\/code><br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"28\" class=\"wp-image-11726\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wpcron-daily.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wpcron-daily.png 766w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-daily-300x14.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-daily-370x17.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-daily-270x13.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-daily-570x27.png.webp 570w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-daily-740x35.png.webp 740w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-daily-150x7.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br><br>By default, WordPress contains the following interval names, and you can use this as part of your command.\u00a0\u00a0<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>hourly:<\/strong> Runs the event once per hour.&nbsp;<\/li>\n\n\n\n<li><strong>twicedaily:<\/strong> Runs the event twice per day (every 12 hours).&nbsp;<\/li>\n\n\n\n<li><strong>daily: <\/strong>Runs the event once per day (every 24 hours).<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Delete a specific Cron Event<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can manually delete a cron event by running the following command. (replace event_name with the event you want to remove)\u00a0<br>\u00a0<br><code>wp cron event delete event_name<\/code><br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"39\" class=\"wp-image-11727\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wpcron-delete.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wpcron-delete.png 518w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-delete-300x20.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-delete-370x24.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-delete-270x18.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wpcron-delete-150x10.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Optimising WP-Cron with UNIX scheduled task<\/strong>&nbsp;<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using a UNIX scheduled task would be more reliable than using WP Cron. Like we mentioned above,&nbsp; wp-cron.php is only triggered when a user visits your website. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With a UNIX scheduled task, you can schedule the task recur at certain intervals or you specify a time for the cron to run.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the other hand, if you have a high traffic website, WP-Cron could be executed multiple times which would put a strain on the server resources and slow down your website. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you choose to use the UNIX method, rather than using WP Cron, you will need to add the following line of code to your wp-config.php file to disable WP Cron:&nbsp;<br>&nbsp;<br><code>define('DISABLE_WP_CRON', true);&nbsp;<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can set up a cron job or &#8216;scheduled task&#8217; in the Scheduled Tasks section of your hosting packages control panel.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Manage Hosting -&gt; Manage -&gt; Scheduled Tasks&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can add a wget command into the command field to call to wp-cron.php which is the function used to trigger your scheduled cron events. Something like the following will work&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>wget -q -O - <a href=\"https:\/\/yourdomain.com\/wp-cron.php?doing_wp_cron\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/yourdomain.com\/wp-cron.php?doing_wp_cron<\/a>&nbsp;<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With My20i, you can run a scheduled task as often as every minute so you can be assured that your Cron Events are never missed!&nbsp;&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Further Optimisation tips<\/strong>&nbsp;<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Avoid Busy Times: <\/strong>If you\u2019ve chosen to schedule a time for when WP-Cron is triggered, avoid busy periods to avoid disruption to your website&#8217;s performance.&nbsp;&nbsp;<\/li>\n\n\n\n<li><strong>Streamline smaller scheduled tasks: <\/strong>Rather than having multiple small tasks scattered across different intervals, arrange for the task to run concurrently or at staggered times during off peak hours.&nbsp;<\/li>\n\n\n\n<li><strong>Space out longer running tasks: <\/strong>If you have a longer running tasks and you need to execute this multiple times, ensure that you have allowed time for the process to complete before executing this again.&nbsp;&nbsp;<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Monitoring and Troubleshooting WordPress Cron Jobs<\/strong>&nbsp;<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are various plugins you can use to monitor WordPress Cron Jobs and to see if they\u2019re running.&nbsp; An example one \u2018<a href=\"https:\/\/wordpress.org\/plugins\/wp-cron-status-checker\/#description\" target=\"_blank\" rel=\"noreferrer noopener\">WP-Cron Status<\/a>\u2019 this plugin logs all hooks running with WP-Cron and if they fail or complete. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You\u2019ll be able to see what ran, when it ran, how long it took, and if it completed. If a WP-Cron hook fails, you will be notified of this soon after via email within 24 hours.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If a WP Cron event fails to run, you can debug this by manually running the event. You can do this using WP Control > Head over to Cron Events > Hover over the Cron Event that you want to test > Click \u2018Run Now\u2019 and check the error logs of your website.\u00a0<br><br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"31\" class=\"wp-image-11721\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/run-now-wp-control.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/run-now-wp-control.png 1709w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/run-now-wp-control-300x16.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/run-now-wp-control-768x40.png.webp 768w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/run-now-wp-control-1536x80.png.webp 1536w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/run-now-wp-control-370x19.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/run-now-wp-control-270x14.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/run-now-wp-control-570x30.png.webp 570w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/run-now-wp-control-740x39.png.webp 740w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/run-now-wp-control-150x8.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In My20i, the error logs are stored in the logs &amp; statistics section of your hosting control panel.\u00a0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"101\" class=\"wp-image-11719\" style=\"width: 600px;\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/logs-and-stats-20i.png\" alt=\"\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/logs-and-stats-20i.png 1157w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/logs-and-stats-20i-300x50.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/logs-and-stats-20i-768x129.png.webp 768w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/logs-and-stats-20i-370x62.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/logs-and-stats-20i-270x45.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/logs-and-stats-20i-570x96.png.webp 570w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/logs-and-stats-20i-740x124.png.webp 740w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/logs-and-stats-20i-150x25.png.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another method would be to use WP-CLI and run the WP Cron event with the &#8211;debug flag which will give you an output which would also contain specific error messages relating to the Cron Event which help you investigate.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can use the following command and replace \u2018event_name\u2019 with the cron event you want to test.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>wp cron event run event_name --debug&nbsp;<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1038\" height=\"168\" src=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wp-debug.png\" alt=\"\" class=\"wp-image-11725\" srcset=\"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/wp-debug.png 1038w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wp-debug-300x49.png.webp 300w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wp-debug-768x124.png.webp 768w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wp-debug-370x60.png.webp 370w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wp-debug-270x44.png.webp 270w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wp-debug-570x92.png.webp 570w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wp-debug-740x120.png.webp 740w, https:\/\/www.20i.com\/blog\/wp-content\/smush-webp\/2023\/11\/wp-debug-150x24.png.webp 150w\" sizes=\"auto, (max-width: 1038px) 100vw, 1038px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Security and WordPress cron jobs<\/strong>\u00a0<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Keeping your WordPress cron secure is very important for various reasons. Here are a couple of examples why:&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Data Protection: <\/strong>WordPress cron jobs can be used to handle sensitive data, such as exporting customer information or backup the websites database. It could be that this data is imported to an external storage facility and using SSL will encrypt the data sent between the two servers and cannot be easily intercepted by malicious actors during transmission.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>DDOS Attacks:&nbsp;<\/strong> The default behaviour of wp-cron.php, if your website receives few visits an hour will be fine but for large websites with more traffic or that are frequently scanned by BOTs, the increase of HTTP\/HTTPS requests can resemble a DDOS Attack on your website because of the additional load. To make this more secure, you can disable WP cron and create a UNIX scheduled task as mentioned above.&nbsp;&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we talked about how you can setup and manage WordPress cron jobs using a plugin and WP CLI. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress crons have their disadvantages and hopefully this article has given you further insight as to why using a true UNIX cron would be better from a performance and security perspective. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How have your experiences been with WP Cron? Would you say that there are advantages using WordPress cron over a true UNIX cron?&nbsp;&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">&nbsp;<\/h2>\n","protected":false},"excerpt":{"rendered":"WordPress Cron jobs are a scheduling system that allows you to automate various tasks within WordPress. Although they\u2019re&hellip;","protected":false},"author":25,"featured_media":11730,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ub_ctt_via":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":"[]"},"categories":[60,293],"tags":[79,76],"class_list":["post-11702","post","type-post","status-publish","format-standard","has-post-thumbnail","category-web-design-dev","category-wordpress","tag-web-development","tag-wordpress","cs-entry"],"featured_image_src":"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2023\/11\/What-are-wordpress-cron-jobs.png","author_info":{"display_name":"Ben Perry","author_link":"https:\/\/www.20i.com\/blog\/author\/benperry92\/"},"_links":{"self":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/11702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/comments?post=11702"}],"version-history":[{"count":8,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/11702\/revisions"}],"predecessor-version":[{"id":11732,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/11702\/revisions\/11732"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/media\/11730"}],"wp:attachment":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/media?parent=11702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/categories?post=11702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/tags?post=11702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}