{"id":3905,"date":"2025-08-14T15:11:00","date_gmt":"2025-08-14T18:11:00","guid":{"rendered":"https:\/\/awp.agency\/?p=3905"},"modified":"2025-12-15T18:08:46","modified_gmt":"2025-12-15T21:08:46","slug":"how-to-set-up-a-real-cron-in-wordpress","status":"publish","type":"post","link":"https:\/\/awp.agency\/en\/blog\/como-configurar-un-cron-real-en-wordpress\/","title":{"rendered":"How to Set Up a Real Cron and Optimize Your WordPress"},"content":{"rendered":"<p class=\"intro\">Are your scheduled posts not being published on time? Automatic backups failing for no apparent reason? Do you notice that your website slows down at certain times? The culprit could be WordPress' scheduled task system, known as WP-Cron. Although its name suggests it, it's not a \"real\" cron, and in this guide we'll show you how to fix it once and for all. In my experience developing WordPress for more than 8 years, learning to <strong>set up a real WP Cron<\/strong> is one of the most important steps to achieve a more reliable, fast and professional website.<\/p>\n\n\t<h2>What is WP-Cron and Why is it not a \"Real Cron\"?<\/h2>\n\n\t<p>To understand the solution, we must first understand the problem. A traditional \"cron job\", in the context of servers (such as Unix\/Linux), is a scheduled task that runs at exact, predefined times. For example, you can tell the server to run a script every day at 3:00 AM, and it will do it with military precision, no matter what.<\/p>\n\n\t<p>However, the system that WordPress uses, <strong>WP-Cron<\/strong>works in a very different way. During my years as a PHP developer, I have seen how this limitation especially affects e-commerce sites where stock synchronizations must be accurate. WP-Cron is not a real cron, but a simulation. Its great weakness is that <strong>is only activated when someone visits your website<\/strong>.<\/p>\n\n\t<p>This is how it works:<\/p>\n\t<ul>\n\t\t<li>Every time a page is loaded on your site (either in the frontend or in the admin panel), WordPress executes the script <code>wp-cron.php<\/code>.<\/li>\n\t\t<li>This script checks the list of scheduled tasks (publications, backups, updates, etc.).<\/li>\n\t\t<li>If it finds a task whose execution time has already passed, it executes it.<\/li>\n\t<\/ul>\n\n\t<div class=\"warning\">\n\t\t<h3>The Fundamental Problem of WP-Cron<\/h3>\n\t\t<p>If your website has little or no traffic during the night, no task scheduled for that period (such as a nightly backup) will run until the first visitor arrives in the morning. This makes WP-Cron an unreliable system for critical tasks.<\/p>\n\t<\/div>\n\n\t<h2>The Dangers of Relying on WP-Cron by Default<\/h2>\n\t<p>Relying on the default WordPress system can bring with it several problems, which are compounded depending on the type of site you manage. I've worked with clients who have lost sales due to failed syncs, and others who have had their SEO degraded by content that wasn't published when it should have been:<\/p>\n\t<ul>\n\t\t<li><strong>Null Reliability in Sites with Low Traffic:<\/strong> As we've already seen, if no one visits your site, the tasks don't run. In the WordPress projects I've developed, this has been especially problematic for e-commerce that need to synchronize stock or for blogs that schedule content during off-peak hours.<\/li>\n\t\t<li><strong>Performance Impact on High Traffic Sites:<\/strong> At the other extreme, if your web site receives thousands of visits, the script <code>wp-cron.php<\/code> will run on each of them. Although the check is fast, these thousands of unnecessary executions add extra load and consume server resources that could be used to serve content to your users faster.<\/li>\n\t\t<li><strong>Unexpected Delays:<\/strong> Tasks are not executed \"at 10:00\", but \"the next time someone visits the site after 10:00\". This can cause delays of minutes or hours.<\/li>\n\t<\/ul>\n\n\t<h2>Methods to Configure a Real WP Cron<\/h2>\n\t<p>There are several methods to implement a real cron in WordPress, from simple solutions to more technical implementations. My approach to increasing revenue for my clients always includes this optimization, as reliability in scheduled tasks is crucial for any online business.<\/p>\n\n\t<h3>Method 1: Traditional Manual Configuration<\/h3>\n\t<p>This is the most universal method and the one that works in virtually any hosting environment.<\/p>\n\n\t<h4>Step 1: Deactivate WP-Cron by default<\/h4>\n\t<p>To prevent WordPress from running <code>wp-cron.php<\/code> on each visit, we must deactivate it. When I develop custom plugins, I always recommend this step as fundamental. To do this, we need to edit the <code>wp-config.php<\/code>.<\/p>\n\t\n\t<div class=\"critical-note\">\n\t\t<p><strong>Attention!<\/strong> Before editing the file <code>wp-config.php<\/code>If you do not make a backup copy of this file, it is essential that you make a backup copy of it. An error in this file can cause your website to stop working.<\/p>\n\t<\/div>\n\n\t<p>Connect to your server through an FTP client (such as FileZilla) or use the File Manager of your hosting panel (cPanel, Plesk, etc.).<br>\n\t2. Locate the file <code>wp-config.php<\/code> in the root directory of your WordPress installation.<br>\n\t3. Download it, edit it with a plain text editor (such as VS Code, Sublime Text or Notepad) and add the following line just before the line that reads <code>\/* That's it, stop editing! Happy blogging. *\/<\/code>:<\/p>\n\n\t<div class=\"code-block\">\n\t\t<pre><code>define('DISABLE_WP_CRON', true);<\/code><\/pre>\n\t<\/div>\n\n\t<p>4. Save the changes and upload the file back to your server, overwriting the original.<\/p>\n\n\t<h4>Step 2: Create a Real Cron Job at Server Level<\/h4>\n\t<p>Now that WordPress is no longer in charge of launching the tasks, we must configure our server to do so. Most hosting panels (cPanel, Plesk, etc.) have a section called \"Cron Jobs\" or \"Scheduled Tasks\".<\/p>\n\t\n\t<p>The command you need to use is usually one of these two:<\/p>\n\t\n\t<p><strong>Option 1 (with <code>wget<\/code>):<\/strong><\/p>\n\t<div class=\"code-block\">\n\t\t<pre><code>wget -q -O - https:\/\/tudominio.com\/wp-cron.php?doing_wp_cron &gt;\/dev\/null 2&gt;&amp;1<\/code><\/pre>\n\t<\/div>\n\t\n\t<p><strong>Option 2 (with <code>curl<\/code>):<\/strong><\/p>\n\t<div class=\"code-block\">\n\t\t<pre><code>curl -s https:\/\/tudominio.com\/wp-cron.php?doing_wp_cron &gt;\/dev\/null 2&gt;&amp;1<\/code><\/pre>\n\t<\/div>\n\n\t<div class=\"good-practice\">\n\t\t<h3>How often should I run the Cron Job?<\/h3>\n\t\t<p>In my experience developing WordPress, a standard and recommended configuration is every 15 to 30 minutes. This frequency ensures that tasks run on time without overloading the server. For high traffic sites, I have used 5 minute intervals with no problems.<\/p>\n\t<\/div>\n\n\t<h3>Method 2: WordPress Toolkit (Plesk)<\/h3>\n\t<p>If your hosting uses Plesk with WordPress Toolkit, you have a much simpler option. In the projects I manage on servers with Plesk, I always use this functionality for its simplicity:<\/p>\n\n\t<ol>\n\t\t<li>Login to your Plesk panel<\/li>\n\t\t<li>Go to \"WordPress Toolkit\".<\/li>\n\t\t<li>Select your WordPress installation<\/li>\n\t\t<li>In the \"Security\" section, look for the \"Take over wp-cron\" option.<\/li>\n\t\t<li>Activate this option<\/li>\n\t<\/ol>\n\n\t<p>That's it! WordPress Toolkit automatically:<\/p>\n\t<ul>\n\t\t<li>Deactivate the internal WP-Cron by adding <code>DISABLE_WP_CRON<\/code> to your <code>wp-config.php<\/code><\/li>\n\t\t<li>Set up a system cron job to run tasks every 5 minutes<\/li>\n\t\t<li>Manage all settings without having to touch code<\/li>\n\t<\/ul>\n\n\t<h3>Method 3: Softaculous<\/h3>\n\t<p>Softaculous, the popular script installer that many hosts include, also offers an option to manage WP-Cron. During my years as a PHP developer, I have found this to be an excellent option for those who are not comfortable editing files manually:<\/p>\n\n\t<ol>\n\t\t<li>Login to your hosting control panel (cPanel, DirectAdmin, etc.)<\/li>\n\t\t<li>Go to the section \"Softaculous Apps Installer\".<\/li>\n\t\t<li>Find your WordPress installation in \"Current Installations\".<\/li>\n\t\t<li>Click on \"Edit Details\" or the configuration icon.<\/li>\n\t\t<li>Look for the option \"Disable WP-Cron\" or \"Disable WP-Cron\".<\/li>\n\t\t<li>Activate this option<\/li>\n\t<\/ol>\n\n\t<p>Like WordPress Toolkit, Softaculous automatically performs a \"takeover\" of the cron system, configuring everything necessary without manual intervention.<\/p>\n\n\t<h3>Method 4: Deployment with Docker<\/h3>\n\t<p>What I have learned working with Docker containers is that cron management requires a specific approach. There are several strategies for implementing a real cron with Docker:<\/p>\n\n\t<h4>Option 1: Cron on Host Server (Recommended)<\/h4>\n\t<p>This is the simplest option and the one I usually recommend in my projects. We configure the crontab directly on the host server:<\/p>\n\n\t<div class=\"code-block\">\n\t\t<pre><code># Run every 5 minutes\n*\/5 * * * * * * * docker exec container_name_wordpress curl -s http:\/\/localhost\/wp-cron.php?doing_wp_cron &gt;\/dev\/null 2&gt;&amp;1<\/code><\/pre>\n\t<\/div>\n\n\t<p>O using <code>wget<\/code>:<\/p>\n\t<div class=\"code-block\">\n\t\t<pre><code># Run every 5 minutes\n*\/5 * * * * * * docker exec wordpress_container_name wget -q -O - http:\/\/localhost\/wp-cron.php?doing_wp_cron &gt;\/dev\/null 2&gt;&amp;1<\/code><\/pre>\n\t<\/div>\n\n\t<h4>Option 2: Integrating Cron into WordPress Container<\/h4>\n\t<p>For projects where I need more integration, I modify the PHP container to include dcron. This requires a custom Dockerfile:<\/p>\n\n\t<div class=\"code-block\">\n\t\t<pre><code>FROM wordpress:php8.2-apache\n\n# Install dcron\nRUN apt-get update &amp;&amp; apt-get install -y cron\n\n# Add cron job\nRUN echo \"*\/5 * * * * * * www-data curl -s http:\/\/localhost\/wp-cron.php?doing_wp_cron &gt;\/dev\/null 2&gt;&amp;1\" &gt;&gt; \/etc\/crontab\n\n# Start cron on container startup\nRUN service cron start<\/code><\/pre>\n\t<\/div>\n\n\t<h4>Option 3: Dedicated Container for Cron<\/h4>\n\t<p>In more complex architectures, I use a dedicated container exclusively to handle cron tasks. This approach is useful when I manage multiple WordPress sites:<\/p>\n\n\t<div class=\"code-block\">\n\t\t<pre><code># docker-compose.yml\nversion: '3.8\n\nservices:\n  wordpress:\n    image: wordpress:latest\n    # ... WordPress container configuration\n\n  wp-cron:\n    image: alpine:latest\n    command: |\n      sh -c \"\n        apk add --no-cache curl\n        echo '*\/5 * * * * * curl -s http:\/\/wordpress\/wp-cron.php?doing_wp_cron &gt;\/dev\/null 2&gt;&amp;1' &gt; \/etc\/crontabs\/root\n        crond -f\n      \"\n    depends_on:\n      - wordpress<\/code><\/pre>\n\t<\/div>\n\n\t<h2>Verification and Management with WP Crontrol<\/h2>\n\t<p>After implementing any of the above methods, I always install the plugin <a href=\"https:\/\/es.wordpress.org\/plugins\/wp-crontrol\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP Crontrol<\/a> to verify that everything is working correctly. In my experience developing WordPress, it is the most reliable tool for monitoring the cron system.<\/p>\n\n\t<p>Once installed and activated, go to <strong>Tools \u2192 Cron Events<\/strong> for:<\/p>\n\t<ul>\n\t\t<li>View a list of all scheduled cron events<\/li>\n\t\t<li>Check your \"Next Run\" to confirm that the actual cron is running<\/li>\n\t\t<li>Execute any task manually<\/li>\n\t\t<li>Manage customized events<\/li>\n\t<\/ul>\n\n\t\n\t<h2>Frequently Asked Questions (FAQ)<\/h2>\n\t\n\t<h3>What if my hosting does not give me access to cron jobs?<\/h3>\n\t<p>If your hosting plan is very basic and does not allow you to set up cron jobs, I have worked with customers who have used external services such as EasyCron or UptimeRobot to make periodic HTTP calls to <code>wp-cron.php<\/code>. However, my recommendation is always to migrate to a <a href=\"https:\/\/awphost.com\/\" target=\"_blank\" rel=\"noopener\">higher quality hosting.<\/a><\/p>\n\n\t<h3>Will deactivating WP-Cron affect the performance of my plugins?<\/h3>\n\t<p>On the contrary, it will improve it. During my years as a PHP developer, I have seen how this optimization solves synchronization problems and improves the user experience. Plugins will still schedule their tasks normally, they will just run more reliably now.<\/p>\n\n\t<h3>How do I know if my real cron is working properly?<\/h3>\n\t<p>In addition to WP Crontrol, in my projects I implement custom logging to monitor the execution of critical tasks. I also use tools like New Relic or custom monitoring for real time alerts.<\/p>\n\n\t<h2>Conclusion: Take Ultimate Control of Your WordPress<\/h2>\n\t<p>Moving away from relying on the WordPress pseudo-crony is a maturity step in managing any serious website. In my experience developing WordPress, this optimization has been key to increasing my clients' revenue by ensuring that all business-critical functionality works when it should.<\/p>\n\n\t<p>Whether using WordPress Toolkit, Softaculous, manual configuration, or Docker deployments, the goal is the same: <strong>reliability, performance and professionalism<\/strong>. Choose the method that best suits your technical environment and give your WordPress the stability it deserves.<\/p>\n\n\t<p>If you have any doubts about the implementation in your specific environment, remember that you can always consult the <a href=\"https:\/\/developer.wordpress.org\/plugins\/cron\/hooking-wp-cron-into-the-system-task-scheduler\/\" target=\"_blank\" rel=\"noopener noreferrer\">official WordPress documentation<\/a> or contact your hosting technical support for specific help.<\/p>","protected":false},"excerpt":{"rendered":"<p>\u00bfTus publicaciones programadas no se publican a tiempo? \u00bfLos backups autom\u00e1ticos fallan sin motivo aparente? \u00bfNotas que tu web se ralentiza en momentos puntuales? El culpable podr\u00eda ser el sistema de tareas programadas de WordPress, conocido como WP-Cron. Aunque su nombre lo sugiera, no es un cron \u00abreal\u00bb, y en esta gu\u00eda te ense\u00f1aremos a [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":3909,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,16],"tags":[],"class_list":["post-3905","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-optimizacion-wordpress","category-servidores-para-wordpress"],"_links":{"self":[{"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/posts\/3905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/comments?post=3905"}],"version-history":[{"count":2,"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/posts\/3905\/revisions"}],"predecessor-version":[{"id":3907,"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/posts\/3905\/revisions\/3907"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/media\/3909"}],"wp:attachment":[{"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/media?parent=3905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/categories?post=3905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/awp.agency\/en\/wp-json\/wp\/v2\/tags?post=3905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}