I’m trying to run a console app with a cron job. By now I’m running it manually to check if it works and it doesn’t.
I have a cron.php file with the following:
<?php
$yii=dirname(__FILE__).'/../../../../yii/framework/yii.php';
$configFile=dirname(__FILE__).'/../config/console.php';
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
$app = Yii::createConsoleApplication($configFile);
$app->run();
And a TestCommand.php file in protected/commands/ folder
<?php
class TestCommand extends CConsoleCommand {
public function run($args)
{
mail('my@mail.com', 'Cron job', 'test');
}
}
Every time I run "php cron.php" via SSH I get this error:
X-Powered-By: PHP/4.4.9
Content-type: text/html
<br />
<b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/homepages/18/d452741994/htdocs/yii/framework/YiiBase.php</b> on line <b>61</b><br />
Why is it showing an error in YiiBase.php? I’ve never touched that file. The line 61 is the first line from the file that is not a comment. The line is “public static $classMap=array();”.
Any idea about what’s going wrong?
EDIT
X-Powered-By: PHP/4.4.9
The problem was the PHP version. Looks like the hosting provider is using PHP 4.4.9 as default version.