2

I have created a php yiic command as

class StartCommand extends CConsoleCommand {

  public function run($params){
    Yii::log("Cron Job has started");        
  }
}

When I run the command php yiic Start, I get the result in the log.

And I have add this to the crontab

 * * * * * /usr/bin/php  /path/app/console/commands/StartCommand.php

But the job is not running. I think I have to mention the php yiic Start to the crontab.

But where do I add it ??

Ajey
  • 7,924
  • 12
  • 62
  • 86

1 Answers1

6
* * * * * cd /path/app/console/commands && php yiic Start
Loïc
  • 11,804
  • 1
  • 31
  • 49
  • @ Ajey : You add it to the crontab and you use the format that Loic gave you. – Mihai P. Mar 07 '14 at 06:35
  • and when I save the crontab, its saving in /tmp/crontab.mek265/crontab. Is this correct? – Ajey Mar 07 '14 at 06:37
  • That's strange. A way to do crontabs is by editing the file `/etc/crontab` (on most linux distributions) – Loïc Mar 07 '14 at 06:38
  • In /etc I have the following things cron.d/ cron.daily/ cron.hourly/ cron.monthly/ crontab cron.weekly/ In which one should I write this job? – Ajey Mar 07 '14 at 06:40
  • just run a `crontab -e` it should work on most distributions. I am not sure who the owner of the /etc/crontab file is or if you should edit it directly. If it is run by the root then you might have problems with access. It is best to use a user that is in the apache group (or the group that runs apache). – Mihai P. Mar 07 '14 at 09:28
  • @Loïc please help me if you can. thanks http://stackoverflow.com/questions/22423084/yii-how-to-call-url-with-yiic – Chalist Mar 16 '14 at 12:58