Codeigniter 2 restrict controller to command line
You might want to check if is a CLI request:
class Mycontroller extends CI_Controller { function __construct() { parent::__construct(); if(!$this->input->is_cli_request()) { // echo 'Not allowed'; // exit(); } }}