【问题标题】:Cron job in codeigniter on cpanel not workingcpanel上codeigniter中的Cron作业不起作用
【发布时间】:2017-11-21 18:30:26
【问题描述】:

我必须在 cpanel 中使用 cron 作业,并且我正在使用 CodeIgniter。我的控制器路径是 http://www.example.com/myfolder/application/controllers/cron/cron_controller.php 我如何在 cron 中调用我的控制器。

【问题讨论】:

标签: php codeigniter cpanel


【解决方案1】:

在 crontab 中简单定义

0 * * * * php /controllers/cron/cron_controller.php

它会起作用,这里*是变量(时间)

Example of job definition:
.---------------- minute (0 - 59)
|  .------------- hour (0 - 23)
|  |  .---------- day of month (1 - 31)
|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
|  |  |  |  |
*  *  *  *  * user-name command to be executed

【讨论】:

    【解决方案2】:

    当您尝试运行 cron 时,您是从命令行运行的,但您仍然需要通过索引。所以你的 cron 命令是:

    * * * * * php index.php cron cron_controller
    

    https://www.codeigniter.com/userguide3/general/cli.html

    【讨论】:

      【解决方案3】:

      这是有效的。只需在 cron 选项卡中输入这个

      wget www.yourdomain.com/index.php/yourcontroller/yourfunction
      

      【讨论】:

        猜你喜欢
        • 2015-01-21
        • 2016-11-08
        • 1970-01-01
        • 2013-03-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多