Welcome Guest, Not a member yet? Register   Sign In
Help with cronjob command line
#1

Hi all,

I am trying to run a controller that I have made for a test (to test cronjob) and I am just struggling at the command line.  I have the following controller

PHP Code:
<?php 

class Reminders extends CI_Controller { public function __construct() { parent::__construct(); 

 
   $this->load->library('input');
 
   $this->load->library('email');
 
   $this->load->model('Appointment_model');
 
 }
 
 public function index()
 
 {
 
   if(!$this->input->is_cli_request())
 
 {
 
     echo "This script can only be accessed via the command line" PHP_EOL;
 
     return;
 
 }
 
 $timestamp strtotime("+1 days");
 
 $appointments $this->Appointment_model->get_days_appointments($timestamp);
 
 if(!empty($appointments))
 
 {
 
     foreach($appointments as $appointment)
 
     {
 
         $this->email->set_newline("\r\n");
 
         $this->email->to($appointment->email);
 
         $this->email->from("[email protected]");
 
         $this->email->subject("Appointment Reminder");
 
         $this->email->message("You have an appointment tomorrow");
 
         $this->email->send();
 
         $this->Appointment_model->mark_reminded($appointment->id);
 
     }
 
 }
 
 }


and I have a Model that is

PHP Code:
<?php

class Appointment_model extends CI_Model
{
 
 public function get_days_appointments($day)
 
 {
 
   $day_start date('Y-m-d 00:00:00'$day);
 
   $day_end date('Y-m-d 23:59:59'$day);
 
   return $this->db->select('*')
 
     ->from('appointments')
 
     ->where('start_time <'$day_start) ->where('start_time >'$day_end)
 
     ->get()->result();
 
      
  
}
 
 
 public function mark_reminded($appointment_id)
 
 {
 
   return $this->db->where('id'$appointment_id)->update('appointments', array('is_reminded' => 1));
 
 }



The example I was given for the cronjob was 

0 13 * * * php [application_path]/index.php cli/reminders

Which states that it will run at 1pm each day.

So I set mine to run a few minutes after using the following.

24 16 * * * php /home/[account_name]/public_html/testing/index.php cli/reminders

But all it did was run the main page of my site.  Thing is I am using the system that it doesn't have the index.php show up when it comes to the pages.

Can anyone help me with the command line to access this controller to run it please.?
Thanks,

Doomie
Reply


Messages In This Thread
Help with cronjob command line - by doomie22 - 07-17-2016, 08:36 AM
RE: Help with cronjob command line - by doomie22 - 07-17-2016, 09:39 AM
RE: Help with cronjob command line - by doomie22 - 07-17-2016, 10:11 AM
RE: Help with cronjob command line - by arma7x - 07-17-2016, 10:28 AM
RE: Help with cronjob command line - by doomie22 - 07-17-2016, 04:08 PM
RE: Help with cronjob command line - by PaulD - 07-17-2016, 04:17 PM
RE: Help with cronjob command line - by doomie22 - 07-17-2016, 05:37 PM
RE: Help with cronjob command line - by PaulD - 07-17-2016, 05:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB