"Problem description":
You need to include a scheduled task in Crontab to execute the Show method in the/data/www/producted/.../timecontroller.php file every day.
To include in a scheduled task:
0 1
*/data/www/producted/.../timecontroller.php Show >/dev/null 2>&1
The method is scheduled to be executed on a daily basis.
However, this method is not called as expected, because timecontroller.php is a class file, and if you want to invoke the method in it, you need to conform to the invocation rules of Yii, so the above notation is invalid.
How do I invoke the methods in the YII framework in crontab. Thank you
Reply content:
"Problem description":
You need to include a scheduled task in Crontab to execute the Show method in the/data/www/producted/.../timecontroller.php file every day.
To include in a scheduled task:
0 1 */data/www/producted/.../timecontroller.php Show >/dev/null 2>&1
The method is scheduled to be executed on a daily basis.
However, this method is not called as expected, because timecontroller.php is a class file, and if you want to invoke the method in it, you need to conform to the invocation rules of Yii, so the above notation is invalid.
How do I invoke the methods in the YII framework in crontab. Thank you
You can only tune command
Demo is as follows
*/1 * * * * /usr/local/php/bin/php /path/to/www/protected/yiic foo bar >> /path/to/log.log 2>&1# yiic 是命令文件 foo 是 命令类,对应 cammand/FooCommand.php # bar 是FooCommand 中的一个方法。
Code that needs to be called in multiple places should not be written in a controller.
Write a command to invoke it.
Crontab calls the PHP script.
The PHP script calls the controller's acrion by means of curl