【问题标题】:i want to run cron job using codeigniter script我想使用 codeigniter 脚本运行 cron 作业
【发布时间】:2017-06-25 20:24:06
【问题描述】:

脚本代码

class Deposit extends MY_Controller
{
   public function coinPaymentCron()
    {
         $this->load->model('user_model','apimodel');

        $apikeys = $this->apimodel->getApiKey();

        foreach ($apikeys as $keysapi) {
            # code...
            $publickey = $keysapi->public_key;

            $privatekey = $keysapi->private_key;
        }

        $cps = new CoinPaymentsAPI();

        $cps->Setup($privatekey, $publickey);

        $getTxIds = $this->apimodel->gettxids();

        foreach ($getTxIds as $txid) {
            # code...

            $tx_id = $txid->txn_id;

            echo $tx_id;

            $txinfo = $cps->gettxinfo($tx_id);

            if ($txinfo['error'] == 'ok') {
                # code...
                $statusText = $txinfo['result']['status_text'];

                $amountReceived = $txinfo['result']['receivedf'];

                $statusPayment = $txinfo['result']['status'];

                $this->apimodel->updateStatus($tx_id, $statusText);
            }
        }
    }
}

我用于运行 cron 作业的代码命令是

/usr/local/bin/php /home/name/public_html/index.php deposit coinPaymentCron

我也尝试了很多方法,比如使用 wget 和 curl,但不幸的是没有一个对我有用。 还使用 url 检查了脚本,脚本运行正常并更新数据库,但 cron 作业未运行。 其他一些 cron 作业正在使用此方法运行

/usr/local/bin/php /home/name/public_html/index.php

任何人都可以就这个问题提供帮助或让我知道我做错了什么吗?

【问题讨论】:

标签: codeigniter


【解决方案1】:

据我所知有很多方法可以调用 CodeIgniter 的函数,例如

这个解决方案对我有用

php /full-path-to-cron-file/cron.php /deposit/coinPaymentCron

另外,你可以试试这个:

wget example.com/index.php/deposit/coinPaymentCron

或者

*/15 * * * * /opt/php55/bin/php /home/username/public_html/myapp/index.php deposit coinPaymentCron

但是您阅读了本教程:http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/ 并按照说明进行操作。对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-05
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多