Help with cronjob command line |
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
07-17-2016, 09:58 AM
(This post was last modified: 07-17-2016, 10:09 AM by albertleao. Edit Reason: Added example )
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 /
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
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.
Have you try command php-cli, it's work for me to run cronjob in cpanel.
Keep calm.
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
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);
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 |
Welcome Guest, Not a member yet? Register Sign In |