Working PHP CRON within CodeIgniter

I am trying to create a CRON job that points to a function inside a file on a Code Igniter system that I created. I created a CRON job on my CPanel and I tested it with a simple post php function inside a file at the root and it works correctly, however I want to point the CRON job to a location in my MVC structure and for some reason apparently not works.

Here is the CRON job installed on my CPanel:

0 0 * * 1 wget -q -O / dev / null http://www.urlhere.co.uk/index.php/cron_event/send_reminders

and here is the controller i want to run. Its location is in system / controllers / cron_event.php:

<?php

class Cron extends Controller {

function Cron_event()
{
    parent::Controller();
}


/**
 * The index method just displays an access denied message, as we don't support viewing this module in the browser.
 */
function index()
{
    $this->send_reminders();
    $this->load->view('themes/base/header', array('title'=>"Access Denied"));
    $this->load->view('cron/access_denied');
    $this->load->view('themes/base/footer');


}


/**
 * Updates the PR Online Calendar by sending out email notifications for events that have not yet had them sent out.
 */

public function send_reminders() {
    $to = 'jamesholman@urlgoeshere.co.uk';
    $from = 'bigwavetest';
    $message = 'test';

    mail($to, $from, $message); 
}
}

?>

      

When I point to this controller, CRON stops working.
I have this feeling because I don't include or require Code Igniter framework files, but I'm not sure. Anyone have any ideas why this is not working?
Thanks in advance!

+3


source to share


1 answer


In your cron call, you put:

wget -q -O /dev/null http://www.urlgoeshere.co.uk/index.php cron_event

      

I think it should be:

wget -q -O /dev/null http://www.urlgoeshere.co.uk/index.php/cron_event

      



Or:

wget -q -O /dev/null http://www.urlgoeshere.co.uk/cron_event

      

If you removed index.php from your url.

+3


source







All Articles