CRON Script execution problem on server

I created a CRON script which simply goes to a controller action and runs the code in that action:


On my hosting server they don’t allow http URLs for the CRON script, so I had to put this in an absolute format from the location of the file on the server. So I did it like this:

/usr/bin/wget /home/sites/ -q

But again did not work. I contacted the tech support who advised as it not at a http request I need explicitly tell it what script to run. So I realised I was using path format URL and it was obviously not rewriting the URL through htaccess. So I did it like this:

/usr/bin/wget /home/sites/ -q

But this has not worked I’m afraid. It seems that you can’t even pass GET variables in to the script via CRON. So what can I do about this?

Create a console command - that definitely works.

It’s a lot better than wget.

First, read this:

Second, I don’t think wget is what you need.

A command should look like:

But first, read about CConsoleCommand.

OK guys, cheers. So I’m going to create a Console script now. The controller action I currently have in SiteController is:

public function actionSendemails()





Will this still work in my Console script if I move it there (and change the function name to actionIndex)?

This is what I have in a cron:

/usr/local/php5/bin/php /home/me/webroot/console.php test arg1 arg2

I made a console.php:


$hostname = $_SERVER['SERVER_NAME'];

// change the following paths if necessary



// 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);


$app = Yii::createConsoleApplication($config);



As you can see, I am using a console config file because it’s not possible to use a web app configuration in console mode.

And then you just create a CConsoleCommand in app/protected/commands.