使用Zend Framework创建cronjob [英] Create cronjob with Zend Framework

查看:154
本文介绍了使用Zend Framework创建cronjob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个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?

会成为一个选项,所以我也可以计算错误和成功?

Would curl be an option, so I also can count the errors and successes?

[更新]

我想我还没有解释。

我想做的是有一个文件,我可以从 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文件来实现。然后我从裸露的最小值:
-my前控制器(index.php)
-my 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

查看东西并专注于保持环境设置,db设置,自动加载器&注册表设置。我不得不花一点时间来更正文档根变量,并删除一些从我的引导复制的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆