Skip to content

Instantly share code, notes, and snippets.

@MattRead
Last active December 12, 2015 00:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattRead/4684480 to your computer and use it in GitHub Desktop.
Save MattRead/4684480 to your computer and use it in GitHub Desktop.
#! /usr/bin/env php
<?php
/**
* Here we fake a request. set these values appropriate to your
* Habari install.
*
* HABARI_PATH is the full file path to the habari install.
* HABARI_SERVER_NAME is the name (domain) of your habari install.
* HABARI_REQUEST_URI is the URL path to your Habari install. "/" for root.
* HABARI_SCRIPTNAME is the URL path to index.php.
*/
const HABARI_PATH = "/var/www/mattread/htdocs";
const HABARI_SERVER_NAME = "mattread.com";
const HABARI_REQUEST_URI = "/";
/**
* Here we setup a request to the home page, and trigger cron to run.
*/
$_SERVER['REQUEST_URI'] = HABARI_REQUEST_URI;
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
$_SERVER['SCRIPT_NAME'] = HABARI_REQUEST_URI . "index.php";
$_SERVER['SERVER_NAME'] = HABARI_SERVER_NAME;
$_SERVER['HTTP_USER_AGENT'] = "Habari Cron Trigger/1.0";
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
const SUPPRESS_REQUEST = true;
require(HABARI_PATH . "/system/index.php");
Controller::parse_request();
$site = Site::get_url('habari');
$stime = microtime(true);
echo "Running Crons for $site\n";
CronTab::run_cron( false );
$etime = microtime(true);
$ttime = $etime - $stime;
echo "Crons for $site finished in $ttime seconds.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment