您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Yii通过控制台命令创建定时任务_PHP教程

2024/10/30 18:44:25发布24次查看
假设yii项目路径为 /home/apps/
1. 创建文件 /home/apps/protected/commands/crons.php
2. 创建需要的配置文件 /home/apps/protected/config/console.php,配置需要的组件、数据库连接,日志等信息,格式类似主配置文件main.php
'mysql:host=xxxx;dbname=xxx', 'emulateprepare' => 'xxx', 'password' => 'xxx', 'charset' => 'utf8', 'tableprefix' => 'tbl_', 3. 在 /home/apps/protected/commands/ 下新建 testcommand 类,继承 cconsolecommand,在testcommand中,可以使用项目的配置信息和yii的各种方法
4. 创建定时任务
$ crontab -e
插入
1 * * * * /home/php/bin/php -f /home/apps/ 即为每小时的第一分钟执行testcommand类中的内容,类似的可以在/home/apps/protected/commands/下新建其他类,使用命令行执行。
http://www.bkjia.com/phpjc/749285.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/749285.htmltecharticle假设yii项目路径为 /home/apps/ 1. 创建文件/home/apps/protected/commands/crons.php ? = '/home/apps/framework/yii.php' ( = ( ).'/../config/console.php' ::createconsoleappli...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product