1

Script code

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);
            }
        }
    }
}

The code command i am using for running cron job is

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

I have also tried many methods like using wget and curl but unfortunately none work for me. Also checked the script using url and the script is running fine and updating the database but the cron job is not running. Some other cron jobs are running using this method

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

Can anyone please help regarding this issue or let me know what I am doing wrong?

CroMagnon
  • 1,218
  • 7
  • 20
  • 32
Amina Rahman
  • 139
  • 1
  • 1
  • 6
  • Possible duplicate of [How to set cron job url for codeigniter?](http://stackoverflow.com/questions/19269566/how-to-set-cron-job-url-for-codeigniter) – kawadhiya21 Feb 08 '17 at 11:02

1 Answers1

0

As I know there are a lot of ways to call function of CodeIgniter e.g.

This solution working for me

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

also, you can try with this:

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

Or

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

But you read this tutorial: http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/ and follow instruction. It will be helpful for you.

Kumar Rakesh
  • 2,718
  • 2
  • 18
  • 39