Cron Dreamhost

I´m trying to execute a Cron in Dreamhost. I have one Command and it works on my machine, howewer I must be missing something to make it work in Dreamhost.

I execute my cron with this in Dreamhost Control Panel:

/home/myUser/myApp/protected/yiic.php updateStatus

My yiic.php is:


<?php


// change the following paths if necessary

$yiic=dirname(__FILE__).'/../../yiiPro/framework/yiic.php';

$config=dirname(__FILE__).'/config/console.php';


require_once($yiic);

I am getting this error:

/home/myUser/myApp/protected/yiic.php: line 1: ?php: No such file or directory

/home/myUser/myApp/protected/yiic.php: line 3: //: is a directory

/home/myUser/myApp/protected/yiic.php: line 4: syntax error near unexpected token `FILE

/home/myUser/myApp/protected/yiic.php: line 4: `$yiic=dirname(FILE).’/../../yiiPro/framework/yiic.php’;’

I don´t write my UpdateStatusCommand because it fails even before to execute the Command, I guess because a bad configuration.

Any idea?

Thanks in advance

How does your cron script look like?

It needs to be using the full path to both php and your command:


/full/path/to/php /full/path/to/yoursite/console.php yourcommand >> /dev/null 2>&1

As you can see, I use console.php to call the command, rather than calling the command directly.

That of course requires that you’ve configured your Yii console application properly. ;)

BTW: Remove the >> /dev/null 2>&1 part and turn on email notifications for the cron script to help you debug it. And add it back in when it works so that you don’t get spammed by cron. :)

Thanks jacmoe. The path to php was the key. Adding it solved my problem.