How to set cron job in yii

主宰稳场 提交于 2019-12-10 18:38:23

问题


I am quite newbie to yii. I am working on a project.

I have written a function to send automatic reminder to clients

say this function is at url :

http://somedomain.com/index.php/somecontroller/someaction

I want to set the cron for this url.

one method is that I should write GET cron_job_url.

But I dont want to use the url for my cron.I only want to use physical path of the controller and action. Is this possible with yii ?


回答1:


If you want to use a cron job, I'd suggest to write a yiic command instead of calling a URL. It's very simple and you don't have to deal with URL access permissions.

Create a new class that extends from CConsoleCommand and implement either a run() method or some actions as you would in a controller. You can find more information on console commands here. You have to save the command to the protected/commands directory and the class name must end in Command.

If your command is called DemoCommand then you can call it from a cron job as /path/to/your/webroot/protected/yiic demo.



来源:https://stackoverflow.com/questions/17235235/how-to-set-cron-job-in-yii

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!