Welcome Guest, Not a member yet? Register   Sign In
Cron job issue - No direct script access allowed
#1

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
Reply
#2

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
A good decision is based on knowledge and not on numbers. - Plato

Reply
#3

(This post was last modified: 05-28-2017, 12:56 AM by Paradinight.)

(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
Reply
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB