2011-03-02 58 views
1

嗨 我想在我的Zendframe工作中实现cron作业。我检查了它的phpinfo,然后我得到了Server API是CGI/FastCGI和SERVER_SOFTWARE是Apache/2.2.15(Unix)mod_ssl/2.2.15 OpenSSL/0.9.8m DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635在zend框架工程中实现cron

所以我意识到我的项目运行在CGI

我是新来的这个克伦工作。我也不知道壳和相关的词。所以,请给我任何好的教程来实现科龙的工作提前

+0

相关:http://stackoverflow.com/questions/5146678/securely-run-cron-jobs-with-zend-framework – takeshin 2011-03-02 08:32:45

回答

1

上crons

http://clickmojo.com/code/cron-tutorial.html

http://www.htmlcenter.com/blog/running-php-scripts-with-cron/

你需要第一件事就是要实现你的脚本任务的逻辑,然后只需运行与crontab的脚本看看这个教程。 使用

crontab -e 

编辑您的crontab文件。

谈到Zend的,你可以

1)把所需的代码在你的控制器

2) - 创建文件夹 “crons” 之一,在你的项目

在这个文件夹中输入一个新的php脚本

- 在你的crontab文件中输入一个cron作业来运行你的脚本

你的crontab文件可能看起来像这样

30 18 * * * php /path-to-your-cron/cron.php 
1

由于只写你的剧本就像你通常做。然后通过运行crontab命令将其添加到crontab

$ crontab -e 


* * * * *  command to be executed 
- - - - - 
| | | | | 
| | | | +----- day of week (0 - 6) (Sunday=0) 
| | | +---------- month (1 - 12) 
| | +--------------- day of month (1 - 31) 
| +-------------------- hour (0 - 23) 
+------------------------- min (0 - 59) 

所以你这可能是

0 */1 * * * /home/user/foo/cron-script.php 

这将运行该脚本每隔一小时。