Skip to content

Instantly share code, notes, and snippets.

@lknight
Created December 17, 2013 13:47
Show Gist options
  • Save lknight/8005148 to your computer and use it in GitHub Desktop.
Save lknight/8005148 to your computer and use it in GitHub Desktop.
wordpress cluster multi site cron script copied from http://www.lucasrolff.com/wordpress/why-wp-cron-sucks/
<?php
require('./wp-load.php');
global $wpdb;
$sql = $wpdb->prepare("SELECT domain, path FROM $wpdb->blogs LIMIT 0,300", '');
$blogs = $wpdb->get_results($sql);
foreach($blogs as $blog) {
$command = "http://" . $blog->domain . ($blog->path ? $blog->path : '/') . 'wp-cron.php?doing_wp_cron';
$ch = curl_init($command);
$rc = curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);
$rc = curl_exec($ch);
curl_close($ch);
}
/*
What you then can do, is to use the command:
*/5 * * * * wget -q -O - "http://mydomain.com/wp-cron-multisite.php?doing_wp_cron=`date +\%s`" > /dev/null 2>&1
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment