Hi everybody!
I’m trying to use the iii-crontab extension in order to create a simple job in my laptop (mac) but it doesn’t seems to do anything.
I have followed all the instructions from the extensions page
http://www.yiiframework.com/extension/yii-crontab/
And this is what I’ve done:
Inside the /protected/extensions/crontab/crontabs folder I have a created a file named ‘resume_crontab’ with the following line:
*/1 * * * * php /Users/user/Documents/workspace/app/yiicmd.php resume
Inside the /protected/commands folder I created a file named ResumeCommand as follows
class ResumeCommand extends CConsoleCommand
{
public function run($args)
{
yiilog('info','Yeah!'); //This is a function in my globals.php
echo 'Yeah!';
}
}
In my app folder, where the index.php is, I have created the yiicmd.php file as follows:
// change the following paths if necessary
$yii=dirname(__FILE__).'/../yii/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/console.php';
$globals=dirname(__FILE__).'/protected/globals/globals.php';
// remove the following line when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
require_once($globals);
require_once($yii);
Yii::createConsoleApplication($config)->run();
My console.php looks like this :
// 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',
'import'=>array(
'application.models.*',
),
// application components
'components'=>array(
'db' => array(
'class' => 'CDbConnection',
'connectionString' => 'mysql:host=localhost;dbname=app',
'emulatePrepare' => true,
'username' => 'app',
'password' => 'app',
'charset' => 'utf8',
'enableProfiling' => true,
'enableParamLogging' => true,
),
// usefull for generating links in email etc...
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => FALSE,
'rules'=>array(),
),
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'class' => 'CFileLogRoute',
'levels' => 'info',
'maxFileSize' => '10240',
'logFile' => 'resume.log',
),
),
),
),
);
For this test I want it to print in the log every minute to see if it works, but nothing happens, and I don’t see any errors.
I have also tried with the crontab -e command from the console, but nothing happens either.
So, how is the job executed? What am I missing?
Thank you very much in advance!
Cheers