我正在尝试编写一个 cronjob 控制器,因此我可以调用一个网站并执行所有模块 cronjob.php.现在我的问题是我该怎么做?
I am trying to write a cronjob controller, so I can call one website and have all modules cronjob.php executed. Now my problem is how do I do that?
curl 是一种选择,所以我也可以计算错误和成功吗?
Would curl be an option, so I also can count the errors and successes?
[更新]
我想我解释得还不够多.
I guess I have not explained it enough.
我想要做的是有一个我可以从 http://server/cronjob 调用的文件,然后让它执行每一个/application/modules/*/controller/CronjobController.php 或者有另一种方式来做,所以所有的 cronjobs 不是在一个地方,而是在模块所在的同一个地方.这会给我带来好处,如果模块不存在,它不会尝试运行其 cronjob.
What I want to do is have one file which I can call like from http://server/cronjob and then make it execute every /application/modules/*/controller/CronjobController.php or have another way of doing it so all the cronjobs aren't at one place but at the same place the module is located. This would offer me the advantage, that if a module does not exist it does not try to run its cronjob.
现在我的问题是你将如何执行所有模块 CronjobController 或者你是否会以完全不同的方式执行它以便它仍然保持模块化?
Now my question is how would you execute all the modules CronjobController or would you do it a completly different way so it still stays modular?
我希望能够给出有多少cronjobs成功运行,有多少没有
And I want to be able to giveout how many cronjobs ran successfully and how many didn't
经过一些研究和大量的拖延,我得出一个简单的结论,即 ZF 化的 cron 脚本应该包含您的 Zend 框架应用程序的所有功能 - 没有所有视图的东西.我通过在我的应用程序目录中创建一个新的 cronjobfoo.php 文件来实现这一点.然后我从以下方面取了最低限度:-我的前端控制器(index.php)-我的bootstrap.php
After some research and a lot procrastination I came to the simple conclusion that a ZF-ized cron script should contain all the functionality of you zend framework app - without all the view stuff. I accomplished this by creating a new cronjobfoo.php file in my application directory. Then I took the bare minimum from: -my front controller (index.php) -my bootstrap.php
我取出了所有的视图内容,专注于保持环境设置、数据库设置、自动加载器和 &注册表设置.我不得不花一点时间来更正文档根变量并删除一些从引导程序复制的 OO 功能.
I took out all the view stuff and focused on keeping the environment setup, db setup, autoloader, & registry setup. I had to take a little time to correct the document root variable and remove some of the OO functionality copied from my bootstrap.
在那之后,我只是编码了..在我的情况下,它正在编译和通过电子邮件发送夜间报告.使用 Zend_Mail 很棒.当我确信我的脚本按照我想要的方式工作时,我只是将它添加到我的 crontab 中.
After that I just coded away.. in my case it was compiling and emailing out nightly reports. It was great to use Zend_Mail. When I was confident that my script was working the way I wanted, I just added it my crontab.
祝你好运!
这篇关于使用 Zend Framework 创建 cronjob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!