Cron Job to execute Yii controller action

I want to use a cronjob to launch a yii action of a controller in order to use all the yii models and AR.

For example I want to launch the action "updateHtcheck" in the controller "HtCheck".

How can I do?

Something like:


* * * * * /usr/local/bin/php -q /path/to/youryii/protected/controller/HtCheck/updateHtcheck

Can someone help me? Thanks :)




GET http://example.com/cron/

wget -O - http://example.com/cron/

lynx --dump http://example.com/cron/ >/dev/null



fixed.

The real problem is that my script is REALLY big and so I’m afraid about:

  1. timeout

  2. memory usage.

So I was talking about executing the php script…

You can’t really just execute controller because it’s a part of web application that is not available at console.

What you can is move all logic from controller to a model/component/class and then use it in console command: http://www.yiiframework.com/doc/guide/topics.console

I do this in almost all my projects.

I have a controller called CronController. It has actions like "actionPurgeCache".

In my crontab, I just use wget to pull that: http://url/cron/purgeCache