How to invoke a method in the Yii framework class in Crontab

Source: Internet
Author: User
"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 中的一个方法。  

    1. Code that needs to be called in multiple places should not be written in a controller.

    2. Write a command to invoke it.

Crontab calls the PHP script.
The PHP script calls the controller's acrion by means of curl

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.