從 cron 呼叫 CodeIgniter 控制器

// application/controllers/Company_controller.php
<?php
if(!defined('BASEPATH'))
    exit('No direct script access allowed');

class Company_controller extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->model('companies_model');    
    }

// cron entry would be something like this:
// 1  1  *  *  *  /usr/bin/php [full path to]/index.php company_controller cronCLI AcmeCorp >/dev/null 2>&1
    public function cronCLI($firmName) {
        if(php_sapi_name() == 'cli') {
            $this->companies_model->doSomeDB_Process($firmName);
        } else {
            echo 'CLI only';
        }
    }
}