示例#1
0
            print_r($options);
            $cron_options['job-id'] = $options['job-id'];
        }
        if ($argc - count($options) - 1 != 2) {
            die("Wrong argument count!\n");
        }
        $when = $argv[$argc - 2];
        $job = $argv[$argc - 1];
        $crontab->load_jobs();
        $crontab->add_job($job, $when, $cron_options);
        $job_id = $crontab->last_job_id();
        $crontab->commit();
        echo "Added job with id={$job_id}\n";
        break;
    case 'remove':
        if (!isset($options['job-id'])) {
            die("Missing job id of job to remove.\n");
        }
        $job_id = $options['job-id'];
        $crontab->load_jobs();
        $list = $crontab->get_jobs();
        if (!isset($list[$job_id])) {
            die("No such job with ID={$job_id}\n");
        }
        $crontab->remove_job($job_id);
        $crontab->commit();
        echo "Removed job.\n";
        break;
}
/** End of file crontab.php **/
/** Location: ./bin/crontab.php **/
示例#2
0
 }
 // Get CLI options
 $options = getopt('', array_values($longopt));
 if ($argc - count($options) - 1 != 1) {
     die('wrong argument count');
 }
 // Make options available through standard keys
 foreach (array_keys($longopt) as $k) {
     if (isset($options[$crontab->_opts[$k]])) {
         $options[$k] = $options[$crontab->_opts[$k]];
     }
 }
 // If is once-job, remove from crontab
 if (isset($options['job-id']) and isset($options['once'])) {
     $crontab->load_jobs();
     $crontab->remove_job($options['job-id'])->commit();
 }
 // If CI index is unknown, try to guess.
 if (!isset($options['ci-index'])) {
     $options['ci-index'] = realpath(dirname(__FILE__) . '/../../index.php');
 }
 if (!file_exists($options['ci-index'])) {
     die('Path to CodeIgniter index unknown! Tried with ' . $options['ci-index'] . "\n");
 }
 // Set URI
 $uri = $argv[$argc - 1];
 if (strpos($uri, '/') != 0) {
     $uri = '/' . $uri;
 }
 $_SERVER['argv'][0] = $options['ci-index'];
 $_SERVER['argv'][1] = $uri;