title: CakePHP 2.3 - cron dispatcher
body: <p>I followed instructions from this website: <a href="http://colorblindprogramming.com/cronjobs-in-cakephp-2-in-5-steps" rel="nofollow">http://colorblindprogramming.com/cronjobs-in-cakephp-2-in-5-steps</a> , but my cronjob does not work.</p>
  
  <p>This is my /app/cron_dispatcher.php:</p>
  
  <pre><code>&lt;?php
  
  if (!defined('DS')) {
      define('DS', DIRECTORY_SEPARATOR);
  }
  
  if (!defined('ROOT')) {
         define('ROOT', dirname(dirname(__FILE__)));
     }
  
     if (!defined('APP_DIR')) {
         define('APP_DIR', basename(dirname(__FILE__)));
     }
  if (!defined('WEBROOT_DIR')) {
      define('WEBROOT_DIR', basename(dirname(__FILE__)));
  }
  if (!defined('WWW_ROOT')) {
      define('WWW_ROOT', dirname(__FILE__) . DS);
  }
  
  if (!defined('CAKE_CORE_INCLUDE_PATH')) {
      if (function_exists('ini_set')) {
          ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
      }
      if (!include('Cake' . DS . 'bootstrap.php')) {
          $failed = true;
      }
  } else {
      if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
          $failed = true;
      }
  }
  if (!empty($failed)) {
      trigger_error("CakePHP core could not be found.  Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php.  It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
  }
  
  App::uses('Dispatcher', 'Routing');
  define('CRON_DISPATCHER',true);
  $Dispatcher = new Dispatcher();
  $Dispatcher-&gt;dispatch(
  new CakeRequest($argv[1]),
  new CakeResponse());
  </code></pre>
  
  <p>And this is my cron controller:</p>
  
  <pre><code>&lt;?php
  App::uses('AppController', 'Controller');
  class CronController extends AppController {
  
      public $name = 'Cron';
      public $uses = array('NewsletterUser'); 
  
      public function beforeFilter() {
          parent::beforeFilter();
          $this-&gt;layout=null;
      }
  
      public function delete_spam() {
          // Check the action is being invoked by the cron dispatcher 
          if (!defined('CRON_DISPATCHER')) { $this-&gt;redirect('/'); exit(); } 
  
          //no view
          $this-&gt;autoRender = false;       
  
  $this-&gt;NewsletterUser-&gt;deleteAll(array("NOT" =&gt; array('NewsletterUser.active' =&gt; 1)), false);  
      }
  }
  </code></pre>
  
  <p>cron call: php /home/somepath/public_html/app/cron_dispatcher.php /cron/delete_spam</p>
  
  <p>Nothing happens, Cron does not work. WHY???</p>