PHP Classes

File: bin/crontab

Recommend this page to a friend!
  Classes of Martin Pircher   PHP Cron Job Manager Script   bin/crontab   Download  
File: bin/crontab
Role: Application script
Content type: text/plain
Description: Auxiliary data
Class: PHP Cron Job Manager Script
Add PHP scripts to be executed periodically
Author: By
Last change: Update of bin/crontab
Date: 9 months ago
Size: 1,299 bytes
 

Contents

Class file image Download
#! /usr/bin/php
<?php
/**
 * sample scheduler to be called via cron(tab), anacron ...
 * @version 2009-11-16 17:49:25 +0100
 * @copyright Martin Pircher <mplx+code@donotreply.at>
 * @author Martin Pircher <mplx+code@donotreply.at>
 * @link http://www.pircher.net/
 * @license http://opensource.org/licenses/MIT MIT License
 * @package Cronjob
 */

use \mplx\toolkit\cronjob\CronJobCmdLine;

/**
 * Check for CLI
 */
if (@php_sapi_name() != 'cli') {
    die(
'ERROR: This script will only work in the shell' . PHP_EOL);
}

/**
 * Include cronjob php class
 */
include dirname(__FILE__) . '/../src/cronjob.php';

/**
 * Include command line class
 */
include dirname(__FILE__) . '/../src/mplx/toolkit/cronjob/CronJobCmdLine.php';

/**
 * Database configuration
 */
$dbcfg = null;
if (isset(
$_SERVER['argv'][1])) {
    if (
file_exists($_SERVER['argv'][1])) {
        include_once
$_SERVER['argv'][1];
    } else {
        echo
"ERROR: cannot find file with database configuration" . PHP_EOL;
    }
}

/**
 * Run the command line processor
 */
try {
   
$cmdline = new CronJobCmdLine($dbcfg);
   
$return = $cmdline->process();
} catch (\
Exception $e) {
    die(
$e->getMessage() . PHP_EOL);
}

if (
$return === true) {
    echo
"DONE.".PHP_EOL;
} elseif (
$return === false) {
    echo
"ERROR.".PHP_EOL;
}