问题
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