Yii crontab command uses tested

Source: Internet
Author: User

Today to use the CRONTAB project is to use the YII framework and then surf the internet to find out how to use the results to get a lot of tips are also the pit of good miserable, and finally the study of their own then realized, so write this article in order to rescue the fog in the Tao friends


YII file structure There is a folder commands if not, build a good directory location and name do not write wrong


The YII framework. The commands for his public and external calls are placed under this folder in its invocation by protected/yiic.php to do the import file.

Configuring YIIC Code


The place to draw the red frame is to be noted

You can see that I commented out the ab area in the code. This place uses the relative path two C area and uses the absolute path. Why do we keep looking down?

Build a file under the commands file testcommand.php code as follows

Class Testcommand  extends Cconsolecommand {public    function run ($args)    {echo ' Test command ';}}

And then we run this script under Linux to see if we can

[Email protected] protected]#  /usr/local/php/bin/php yiic.php  Test >> commands/t.log

I explain this line of code: first into the project Protected folder,/usr/local/php/bin/php this paragraph is your PHP executable location is equivalent to the window under the PHP installation directory Php.exe file location yiic.php This entrance file, test, is the command file we just built. >> Commands/t.log What does this mean? The result is entered into this T.log file.

This time can if you yiic.php in the file with a relative path, you may appear to include the file does not exist error, the solution, the first you put that path into the log file to see if the path is correct and then to change the right, there is a way to use absolute path, However, it is important to note that absolute paths are easy but once you change the environment, there may be some differences in the directory structure that can cause the include files to be missing.

In this place may also hold a mistake, that is, yiic.php is not allowed to access the wrong you can modify the permissions of YIIC to solve, as to how to put this command in Crontab let the system run their own time to Google Bar, welcome to point out the document error content, I will promptly revise, study together.


Yii crontab command uses tested

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.