Skip to content

Instantly share code, notes, and snippets.

@keichan34
Created January 29, 2014 01:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save keichan34/8679936 to your computer and use it in GitHub Desktop.
A simple script, intended to be run in the context of a WordPress install -- `wp-cli`'s `eval-file` is the easiest way -- to ping the cron of all sites registered in the network.
<?php
$start_date = date_i18n('Y/m/d H:i:s');
$start_time = microtime(true);
echo "Start site-wide wp-cron at $start_date\n";
$sites = wp_get_sites();
foreach ($sites as $site) {
$url = "http://" . $site['domain'] . $site['path'];
echo "Ping wp-cron.php for `$url` ... ";
file_get_contents($url . 'wp-cron.php');
echo "OK.\n";
}
$end_time = microtime(true);
$end_date = date_i18n('Y/m/d H:i:s');
$time = ($end_time - $start_time);
echo "Finished at $end_date ($time s)\n\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment