Yii Framework Forum: crontab help please! - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

crontab help please! Rate Topic: -----

#1 User is offline   bigardusklei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 04-January 11
  • Location:Asturias, Spain

Posted 01 September 2011 - 12:05 PM

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.yiiframew...on/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
0

#2 User is offline   bigardusklei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 04-January 11
  • Location:Asturias, Spain

Posted 01 September 2011 - 12:36 PM

By the way...
I there a need to use the extension if I use the crontab commando from linux?
0

#3 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 01 September 2011 - 12:46 PM

Perhaps the cron daemon isn't started? (I had to enter cron from the command line when first trying out crontab.)

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#4 User is offline   bigardusklei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 04-January 11
  • Location:Asturias, Spain

Posted 02 September 2011 - 04:57 AM

I already solved it. I didn't had to use the extension, just the crontab, and it did worked well. Thanks anyway!
Cheers!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users