使用 CakePHP 执行定时任务

编程入门 行业动态 更新时间:2024-10-27 16:33:40
本文介绍了使用 CakePHP 执行定时任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经提到了bakery.cakephp/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 框架结构:

  • 创建

    F:websitesprojectnameappvendorsshellsfilename.php

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

  • 2.设置754权限到F:websitesprojectnamecakeconsolecake

  • 将 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 bakery.cakephp/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:

  • 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","Test","Test"); } }

  • 2.set 754 permission to F:websitesprojectnamecakeconsolecake

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

    /dev/null 2>&1: for Suppressing warning/error/msg from server

  • Thank you Nidhin

    更多推荐

    使用 CakePHP 执行定时任务

    本文发布于:2023-11-06 07:39:06,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1563096.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:CakePHP

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!