Yii Framework Forum: Cron Dreamhost - Yii Framework Forum

Jump to content

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

Cron Dreamhost Rate Topic: -----

#1 User is offline   julitus 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 16-May 12

Posted 02 January 2013 - 07:38 AM

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
0

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 02 January 2013 - 08:43 AM

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. :)
"Less noise - more signal"
0

#3 User is offline   julitus 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 16-May 12

Posted 02 January 2013 - 10:12 AM

View Postjacmoe, on 02 January 2013 - 08:43 AM, said:

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.
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