I tried to run CRON from Command Prompt. Its not working.
I have created cron.php in webroot which is copy of index.php, just change code
App::uses('Dispatcher', 'Routing');
define('CRON_DISPATCHER',true);
if($argc == 2) {
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest($argv[1]), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
}
Now, I ran CRON in command prompt using
E:/wamp/bin/php/php5.4.12/php.exe E:/wamp/www/warehouse/admin/webroot/cron.php cron/test.
In my test function i wrote code,
$this->layout=null;
//Check the action is being invoked by the cron dispatcher
if (!defined('CRON_DISPATCHER')) { $this->redirect('/'); exit(); }
//$this->autoRender = false;
$my_file = 'E:/wamp/www/warehouse/admin/webroot/file.txt';
$handle = fopen($my_file, 'a') or die('Cannot open file: '.$my_file);
$data = 'New data line 1';
fwrite($handle, $data);
fclose();
echo "success";
exit;
But its not create file in webroot and doesn't display any error.
Can anyone help me?