【问题标题】:Cron job in CodeIgniter doesn't workCodeIgniter 中的 Cron 作业不起作用
【发布时间】:2018-05-24 16:50:56
【问题描述】:

我这样设置我的 cron 作业。这是我的命令

php public_html/project_name/index.php cron cronExec

cronExec 是我的控制器名称 cron 中的一个函数。这会将数据保存到我的数据库中。

无论如何,index.php 真的需要输入命令吗?我将我的 config.php 设置为这段代码:

$config['index_page'] = ''; 

它应该每分钟执行一次,我已经在我的 cron 作业中设置了它,但它不起作用。

【问题讨论】:

    标签: php codeigniter cron


    【解决方案1】:

    如果您使用的是Linux服务器,请尝试以下方法

    在 cli 类型以下,

    crontab -e
    

    它将在编辑器中打开corntab配置文件,然后插入以下行并保存。

    */60 * * * * wget -O /dev/null http://YourLocalhost/PathToYourFunction
    

    此 URL 将由您的服务器每隔 1 分钟执行一次。

    【讨论】:

      【解决方案2】:

      您需要将完整的绝对路径设置为index.php

      【讨论】:

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