Welcome Guest, Not a member yet? Register   Sign In
cron job via cli codeIgniter v3
#1

(This post was last modified: 03-18-2021, 11:39 AM by php_rocs.)

Hello, I bought a marketplace module pre-developed with codeIgniter.
I am stuck on a very important point on which you could perhaps help me.
Indeed, regarding cron jobs, codeIgniter provides for the call via the http protocol.
For various reasons (in particular the need to call scripts in python in my cron), I want to be able to launch my cron via the cli (ie from the command line). I looked at the codeIgniter documentation but the example given does not work for me. 

This is due to the fact that I bought a pre-developed module and there are additional roadblocks..
I have created a cli.php file at the root as follow


Code:
#!/usr/bin/php

<?php

/* make sure this isn't called from a web browser */

if (isset($_SERVER['REMOTE_ADDR'])) die('Permission denied.');


/* set the controller/method path */

//$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'] = '/cron_controller/update_sitemap';

$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'] = $argv[1];


/* raise or eliminate limits we would otherwise put on http requests */

set_time_limit(0);

ini_set('memory_limit', '256M');



/* call up the framework */

include(dirname(__FILE__).'/index.php');

?>
my cron_controller file as below


Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Cron_controller extends Home_Core_Controller
{

    public function __construct()
    {
        parent::__construct();
    }

    /**
    * Update Sitemap
    */
    public function update_sitemap()
    {
        $this->load->model('sitemap_model');
        $this->sitemap_model->update_sitemap();
    }


}

when typing in the command line 
php cli.php cron_controller update_sitemap

I get the following error :
Invalid License Code

in my Common.php file there is a function :
Code:
if (!function_exists('res_lcs_common')) {
    function res_lcs_common()
    {
        echo "Invalid License Code";
    }
}

but it works well - when calling with bibelotandco.fr/cron_controller/update_sitemap

I have to pass through this error with cli but have no idea to do that.

Thank you for your help
Reply




Theme © iAndrew 2016 - Forum software by © MyBB