I created a CRON script which simply goes to a controller action and runs the code in that action:
/localhost/site/sendemails
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:
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/local/php5/bin/php /home/me/webroot/console.php test arg1 arg2
I made a console.php:
<?php
$hostname = $_SERVER['SERVER_NAME'];
// 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);
$app = Yii::createConsoleApplication($config);
Yii::app()->setTimeZone("UTC");
$app->run();
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.