本文介绍了使用 CakePHP 执行定时任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经提到了http://bakery.cakephp.org/articles/view/calling-controller-actions-from-cron-and-the-command-line 并创建了 cron_dispatcher.php 并将其放在应用程序文件夹中.>

我已经返回了一些用于 cron 作业的测试电子邮件函数,以便在我的用户控制器的测试方法中运行.

而且我在我的网络服务器的控制面板中创建了一个 Cron 作业,如

"/usr/bin/php/home4/enventur/public_html/pennystock/cron_dispatcher.php/users/test"

但是它给了我一个错误没有指定输入文件."

请帮帮我,如何解决??

提前致谢

解决方案

我采用了不同的方式,

请查看步骤,它可能对其他人有帮助..

Cron/Shell 使用 Cakephp 框架结构:

  1. 创建

    F:websitesprojectnameappvendorsshellsfilename.php

    class ClassName extends Shell {//var $uses = array('Post');//型号名称//主函数总是在shell执行时运行函数主(){邮件(nidhin@2basetechnologies.com",测试",测试");}}

2.设置754权限到F:websitesprojectnamecakeconsolecake

  1. 将 cron 作业设置为 /home4/enventur/public_html/pennystock/cake/console/cake -app "/home4/enventur/public_html/pennystock/app" ClassName >/dev/null 2>&1

    /dev/null 2>&1: 用于抑制来自服务器的警告/错误/消息

谢谢尼丁

I have referred http://bakery.cakephp.org/articles/view/calling-controller-actions-from-cron-and-the-command-line and created cron_dispatcher.php and placed it in the app folder.

I have return some test email function for the cron job to run in my users controller's test method.

And i have created a Cron job in my web server's control panel like

"/usr/bin/php/home4/enventur/public_html/pennystock/cron_dispatcher.php /users/test"

But its giving me an error as "No input file specified."

Please help me, how to solve it ??

Thanks in Advance

解决方案

I have done it in different way,

Please see the steps, it may helpful for others..

Cron/Shell Using Cakephp Framework Structure:

  1. create

    F:websitesprojectnameappvendorsshellsfilename.php

    class ClassName extends Shell {
        //var $uses = array('Post'); //name of Model
    
        //Main function runs always when shell executes
        function main() {
            mail("nidhin@2basetechnologies.com","Test","Test");
        }
    }
    

2.set 754 permission to F:websitesprojectnamecakeconsolecake

  1. Set cron job as /home4/enventur/public_html/pennystock/cake/console/cake -app "/home4/enventur/public_html/pennystock/app" ClassName >/dev/null 2>&1

Thank youNidhin

这篇关于使用 CakePHP 执行定时任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 00:43