title: Yii - How to access to model and call action in yiic
body: <p>I have an action that prints "Hello World":</p>
  
  <pre><code>public function actionStart()
  {
      echo 'Hello World';
  }
  </code></pre>
  
  <p>I will to run a cron job that calls this action every minute.</p>
  
  <p>How I can do this with yiic ? </p>
  
  <hr>
  
  <h1>UPDATE:</h1>
  
  <p>I create console app. I have cron.php inside index.php:</p>
  
  <pre><code>&lt;?php
  defined('YII_DEBUG') or define('YII_DEBUG',true);
  
  // including Yii
  require_once('framework/yii.php');
  
  // we'll use a separate config file
  $configFile='protected/config/c.php';
  
  // creating and running console application
  Yii::createConsoleApplication($configFile)-&gt;run();
  </code></pre>
  
  <p>and config/c.php:</p>
  
  <pre><code>&lt;?php
  return array(
      // This path may be different. You can probably get it from `config/main.php`.
      'basePath'=&gt;dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
      'name'=&gt;'Cron',
  
      'preload'=&gt;array('log'),
  
      'import'=&gt;array(
          'application.models.*',
          'application.components.*',
      ),
      // We'll log cron messages to the separate files
      'components'=&gt;array(
          'log'=&gt;array(
              'class'=&gt;'CLogRouter',
              'routes'=&gt;array(
                  array(
                      'class'=&gt;'CFileLogRoute',
                      'logFile'=&gt;'cron.log',
                      'levels'=&gt;'error, warning',
                  ),
                  array(
                      'class'=&gt;'CFileLogRoute',
                      'logFile'=&gt;'cron_trace.log',
                      'levels'=&gt;'trace',
                  ),
              ),
          ),
  
          // Your DB connection
          'db'=&gt;array(
              'class'=&gt;'CDbConnection',
              // …
          ),
      ),
  );
  </code></pre>
  
  <p>and protected/commands/MyCommand.php:</p>
  
  <pre><code>&lt;?php
  class MyCommand extends CConsoleCommand
  {
      public function run($args)
      {
          $logs = Log::model()-&gt;findAll();
          print_r($logs);
          die();
      }
  }
  </code></pre>
  
  <p>when I run this:</p>
  
  <pre><code>$ ./protected/yiic my
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre><code>PHP Error[2]: include(Log.php): failed to open stream: No such file or directory
      in file /path/to/app/folder/framework/YiiBase.php at line 427
  #0 /path/to/app/folder/framework/YiiBase.php(427): autoload()
  #1 unknown(0): autoload()
  #2 /path/to/app/folder/protected/commands/MyCommand.php(6): spl_autoload_call()
  #3 /path/to/app/folder/framework/console/CConsoleCommandRunner.php(71): MyCommand-&gt;run()
  #4 /path/to/app/folder/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner-&gt;run()
  #5 /path/to/app/folder/framework/base/CApplication.php(180): CConsoleApplication-&gt;processRequest()
  #6 /path/to/app/folder/framework/yiic.php(33): CConsoleApplication-&gt;run()
  #7 /path/to/app/folder/protected/yiic.php(7): require_once()
  #8 /path/to/app/folder/protected/yiic(3): require_once()
  </code></pre>
  
  <p>How I can fix this?</p>