InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Wordpress customization tutorials

  • Handle pagination in wordpress custom php code
  • How to and why disable wordpress cron
  • How to customize wordpress image alt tag
  • How to display date in wordpress pages
  • How to display wordpress page list with specific custom field value
  • How to display wordpress top level pages
  • How to hide a post from home and RSS feed in wordpress
  • How to include bootstrap javascript and css in wordpress post
  • How to include wordpress pages in archives
  • How to override priority and change frequency in Yoast xml sitemap
  • How to remove xmlrpc from wordpress headers
  • How to setup wordpress custom query params with pretty url format
  • How to show wordpress pages on front page with skip_home custom field
  • How to use google custom search for wordpress site
  • How to write custom php in wordpress
  • No frills social share links for Wordpress sites
  • Using Wordpress custom field for displaying code
  • Wordpress - add content filter after shortcode execution
  • Wordpress - customize category and tag links
  • Wordpress - customize facebook plugin opengraph meta tags
  • Wordpress - customize posts per page for tag, category and date archive pages
  • Wordpress - exclude specific posts from archive pages
  • Wordpress - get posts/pages with missing meta key
  • Wordpress - how to add filter to description meta tag
  • Wordpress - how to create custom tag cloud
  • Wordpress - how to exclude specific tag posts from a tag archive page
  • Wordpress - write custom php log to separate file
  • Wordpress how to check if a post is being viewed by admin
 
  • Home
  • > Tutorials
  • > Wordpress
  • > Wordpress customization

How to and why disable wordpress cron

By admin | Last updated on Mar 20, 2016

WordPress crons are different from traditional Linux or Windows crons. Traditional cron runs as independent processes at regular interval. WordPress crons are php hooks which piggy back on a visitor requests. Few points to note in wordpress crons:

  1. When a cron is scheduled, it is run the moment a user visits the site after the scheduled time. So the running time can be much later than scheduled time.
  2. The cron may slow down the user request. Here is the action hook in default-filters.php which is used to invoke cron code:
    add_action( 'init', 'wp_cron' );

    Checking and running crons in each user request can potentially impact performance.

  3. At each user request wordpress checks for the existence of any scheduled cron and calls spawn_cron. Here is code snippet from spawn_cron function in cron.php
    $cron_request = apply_filters( 'cron_request', array(
    'url' => site_url( 'wp-cron.php?doing_wp_cron=' . $doing_wp_cron ),
    'key' => $doing_wp_cron,
    'args' => array( 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) )
    ) );wp_remote_post( $cron_request['url'], $cron_request['args'] );

    It seems that it has a low timeout and its a non blocking wp_remote_post. So it should not impact the user thread too much. But if there are to many crons activities, it may still have some impact on user request response time.

In you own your own Linux hosting server (or any other) then a better approach is to disable the wordpress cron and setup a Linux cron. Here are the steps:

  1. Add this entry to wp-config.php
    define('DISABLE_WP_CRON', true);

    This will ensure that no cron related work in done in any user request. This will reduce some mysql database queries also.

  2. Setup a Linux cron after every 5 min or so.
    */5 * * * * wget -q -O - https://infoheap.com/wp-cron.php

    You can run it less frequently in case you don’t have any cron task which need that kind of frequency.

I prefer to keep the user request thread as light and simple as possible. This lead to overall a better user experience.

Suggested posts:

  1. Jenkins – how to setup build failure email
  2. How to use dropbox as mini webserver
  3. WordPress – how to add filter to description meta tag
  4. How to include bootstrap javascript and css in wordpress post
  5. How to upgrade EC2 Ubuntu Linux micro instance to small
  6. How to display wordpress top level pages
  7. Chrome enable webgl on old macbooks
  8. How to add tag and category to wordpress pages
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Tutorials, Webmaster, Wordpress, Wordpress customization
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress