• I disabled cron job for every domain I have with php code define(‘DISABLE_WP_CRON’, true);
    When I want to create “real cron” like my hosting says, do I need to create it for every domain I have separately?

Viewing 3 replies - 1 through 3 (of 3 total)
  • if you disable
    define('DISABLE_WP_CRON', true);
    you have to call it manually via file path.
    https://yourdomain.com/wp-cron.php?doing_wp_cron replace https://yourdomain.com/ with your domain and / or https.

    a multisite installation requires that the core files are installed only once and if the main site and the secondary site have different domains you have to do what your hosting shows you.
    Some hosting services have the multisite parameter (or the absolute local path example /home/user/wp-cron.php?doing_wp_cron) and will work in any domain and will always point to the path of the wp-cron.php? doing_wp_cron file.

    note * you must have already created the file wp-config.php which will call wp-settings.php otherwise without file wp-config.php when you call wp-cron.php?doing_wp_cron which in turn calls wp-load.php will start a new installation.
    only if your hosting adds the timestamp in doing_wp_cron otherwise ask them for more information. example doing_wp_cron=1560090633.5487570762634277343750

    Thread Starter nikola797992

    (@nikola797992)

    I have created a cron in cpanel like this –
    cd /home/username/public_html; /usr/local/bin/php -q wp-cron.php
    I did that using this tutorial – https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/configuring-a-cron-job-for-wordpress
    But I don’t know if that covers all my subdomains?

    each configuration is different from hosting A and hosting B.
    You must follow the guide of your hosting.
    If the main domain and the subdomains are in the center of the language, it is absolutely your hosting will change based on the HTTP_HOST variable from the browser .. (it is not the only way but one of the most used).
    You need to ask your host for more information as follows: I have a wordpress multisite with main domain end subdomains, how can I enable cron jobs for the main domain and subdomains?

    After you get this answer I write you a php code to do your tests (I want to know if the hosting up is based on HTTP_HOST to distinguish the domains).
    I modified the previous post with this post.

    wp-cron.php offer three method

    // Use global $doing_wp_cron lock otherwise use the GET lock. If no lock, trying grabbing a new lock.
    if ( empty( $doing_wp_cron ) ) {
    	if ( empty( $_GET['doing_wp_cron'] ) ) {
    		// Called from external script/job. Try setting a lock.
    		if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) ) {
    			return;
    		}
    		$doing_cron_transient = $doing_wp_cron = sprintf( '%.22F', microtime( true ) );
    		set_transient( 'doing_cron', $doing_wp_cron );
    	} else {
    		$doing_wp_cron = $_GET['doing_wp_cron'];
    	}
    }

    Example
    wp-cron.php with set variable $doing_wp_cron or
    wp-cron.php or
    wp-cron.php?doing_wp_cron=1560090633.5487570762634277343750

    • This reply was modified 5 years, 5 months ago by autotutorial.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Setting cron for multiple domains’ is closed to new replies.