CodeIgniter Forums
Cron job issue - No direct script access allowed - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Cron job issue - No direct script access allowed (/showthread.php?tid=68117)



Cron job issue - No direct script access allowed - window077 - 05-27-2017

Hi, I'm having trouble getting a cron job to run:

=====


The file that I need the cron to run is located at:
Code:
/home/user/public_html/application/modules/cron/controllers/cron.php

The command for the cron is:
Code:
/usr/local/bin/php /home/user/public_html/application/modules/cron/controllers/cron.php Cron index

The file cron.php contains:
<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Cron extends Front_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('cron_model');
    }

    public function index() {
        $this->check_on_grace_period(); //checks for grace period if passed disable account
    }
}

The error after the cron runs is:
No direct script access allowed

=====

What am I doing wrong?  Any help would be amazing, thanks Smile


RE: Cron job issue - No direct script access allowed - salain - 05-28-2017

Hi,

You need to run the index.php with the controller method param
so in your case this should work:
/usr/local/bin/php /home/user/public_html/index.php cron index


RE: Cron job issue - No direct script access allowed - Paradinight - 05-28-2017

(05-27-2017, 10:16 PM)window077 Wrote: Hi, I'm having trouble getting a cron job to run:

=====


The file that I need the cron to run is located at:
Code:
/home/user/public_html/application/modules/cron/controllers/cron.php

The command for the cron is:
Code:
/usr/local/bin/php /home/user/public_html/application/modules/cron/controllers/cron.php Cron index

The file cron.php contains:
<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Cron extends Front_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('cron_model');
    }

    public function index() {
        $this->check_on_grace_period(); //checks for grace period if passed disable account
    }
}

The error after the cron runs is:
No direct script access allowed

=====

What am I doing wrong?  Any help would be amazing, thanks Smile

https://www.codeigniter.com/user_guide/general/cli.html
Code:
/usr/local/bin/php /home/user/public_html/index.php cron index

change cron.php to Cron.php


RE: Cron job issue - No direct script access allowed - window077 - 05-29-2017

That worked a treat! Many, many thanks for the advice Smile