![]() |
Help with cronjob command line - 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: Help with cronjob command line (/showthread.php?tid=65731) |
Help with cronjob command line - doomie22 - 07-17-2016 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 and I have a Model that is PHP Code: <?php 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 RE: Help with cronjob command line - doomie22 - 07-17-2016 All it is doing is running the the main page. Can anyone help RE: Help with cronjob command line - albertleao - 07-17-2016 You're not running the command correctly: http://www.codeigniter.com/user_guide/general/cli.html Code: $ cd /path/to/project; The controller and method are separated by a space not a / RE: Help with cronjob command line - doomie22 - 07-17-2016 I had the controller in a folder called cli, so I moved it in to the main controller folder and changed it to this. php /home/[account_name]/public_html/testing/index.php reminders It still sends the report of the standard main page html to me in the cron job report. P.S. I am running this through cPanel Cron Jobs on my hosting. RE: Help with cronjob command line - arma7x - 07-17-2016 Have you try command php-cli, it's work for me to run cronjob in cpanel. RE: Help with cronjob command line - doomie22 - 07-17-2016 Thank you for all the help. It seems to be running as if I just try to send an email with simple code it comes through, but what seems to happen atm is this code is running but its not doing anything, but I think it could be because it is not getting to the database. Can someone take a look at this please. PHP Code: <?php RE: Help with cronjob command line - PaulD - 07-17-2016 Perhaps your appointments model is not returning any appointments. RE: Help with cronjob command line - doomie22 - 07-17-2016 Ok, after much messing and testing, I have got it to work but there is just something wrong with 4 lines. in the controller its PHP Code: $timestamp = strtotime("+1 days"); in the model PHP Code: $this->db->where('start_time < ', $day_start); If I take out the where in the model it all works perfectly (for a test), I add this to just get the next day appointments and nothing happens as it cannot find any (even though there is one on every day for the next 6 days). Can anyone see what I am missing with it as the time system has always been my weak point. Just incase, here is the day_start and day_end incase its theses too. PHP Code: $day_start = date('Y-m-d 00:00:00', $day); RE: Help with cronjob command line - PaulD - 07-17-2016 You are asking it to be less than when the day starts, and greater than when the day ends, that surely will not return anything Change PHP Code: $this->db->where('start_time < ', $day_start); To PHP Code: $this->db->where('start_time > ', $day_start); Best wishes, Paul |