I am attempting to create a CRON job which points to a function inside a file in a Code Igniter system I have built.
I have created the CRON job on my CPanel and I have tested it using a simple mail php function inside a file at the root and this works correctly, however, I wish to point the CRON job to a location within my MVC framework and for some reason this does not seem to be working.
Here is the CRON job set up 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 wish to run. The location of it is in the 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 the CRON job stops working.
I have a feeling it is because I am not including and requiring the Code Igniter framework files but am unsure.
Does anybody have any ideas as to why this isn’t working?
Thanks in advance!
In your cron call you put:
I think it must be:
Or:
If you removed index.php from your URL.