hi all, i want to ask how use crontab step by step from the first time.
i just read from this link
yii-crontab extension
and it error said that no table1, and i don’t know where to put the code below Usage
See the following code example
and i read this http://www.yiiframework.com/wiki/91/implementing-cron-jobs-with-yii
and i din’t know where is crontab.
in example i made this console (in commands\TestCommand.php):
<?php
class TestCommand extends CConsoleCommand
{
public function run($args)
{
echo "test test test";
}
}
and i have a console.php in htdocs\myfolder
<?php
//require(dirname(__FILE__).'/protected/global.php');
// change the following paths if necessary
$yii=dirname(__FILE__).'/../../../yii/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/console.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
Yii::createConsoleApplication($config)->run();
and in (config\console.php)
<?php
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// application components
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.user.models.*',
'application.modules.user.components.*',
'application.modules.rights.models.*',
'application.modules.rights.components.*',
'application.extensions.*',
'application.models.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'rights'=>array(
'install'=>true,
'superuserName'=>'Admin',
'authenticatedName'=>'Authenticated',
'userClass'=>'Users',//class tablenya
'userIdColumn'=>'id',
'userNameColumn'=>'username',
),
'user',
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'superdodo',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','10.12.12.95'),
),
),
// application components
'components'=>array(
'user'=>array(
'class'=>'RWebUser',
'allowAutoLogin'=>true,
'loginUrl' => array('/user/login'),
),
'authManager'=>array(
'class'=>'RDbAuthManager',
'connectionID'=>'db',
),
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=cbc',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'logFile'=>'logFILEs',
'logPath'=>'C:/xampp/htdocs/tes/',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
array(
'class'=>'CWebLogRoute',
),
),
),
'excel'=>array(
'class'=>'application.extensions.PHPEXCEL',
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
),
);
i want to make the TestCommand do the task every ten minute, and it write the log to the log file
i really new with this, can someone help me?
thanks