我试着从命令提示符运行CRON。它不工作。
我已经在webroot中创建了cron.php,这是index.php的副本,只是更改代码
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'))));
}
现在,我在命令提示符下使用
您的位置:我的位置:凡人谷知道〉教育/科学〉教育/科学
在我的测试函数中我写了代码,
$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;
但它不会在webroot中创建文件,也不会显示任何错误。
有人能帮帮我吗?
1条答案
按热度按时间50pmv0ei1#
我也遇到了同样的问题,我在控制器里加了这个,效果很好