php - CakePHP 2.3 - cron dispatcher -


i followed instructions website: http://colorblindprogramming.com/cronjobs-in-cakephp-2-in-5-steps , cronjob not work.

this /app/cron_dispatcher.php:

<?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 not found.  check value of cake_core_include_path in app/webroot/index.php.  should point directory containing " . ds . "cake core directory , " . ds . "vendors root directory.", e_user_error); }  app::uses('dispatcher', 'routing'); define('cron_dispatcher',true); $dispatcher = new dispatcher(); $dispatcher->dispatch( new cakerequest($argv[1]), new cakeresponse()); 

and cron controller:

<?php app::uses('appcontroller', 'controller'); class croncontroller extends appcontroller {      public $name = 'cron';     public $uses = array('newsletteruser');       public function beforefilter() {         parent::beforefilter();         $this->layout=null;     }      public function delete_spam() {         // check action being invoked cron dispatcher          if (!defined('cron_dispatcher')) { $this->redirect('/'); exit(); }           //no view         $this->autorender = false;         $this->newsletteruser->deleteall(array("not" => array('newsletteruser.active' => 1)), false);       } } 

cron call: php /home/somepath/public_html/app/cron_dispatcher.php /cron/delete_spam

nothing happens, cron not work. why???

ignore page, gives false advice , proposes bad architecture. it's wrong.

instead should use shell that. see page in cakephp book shells.

your application, if written, should have data processing , manipulation code inside model. code easy share between controller , shell.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -