Codeigniter CRON / CLI to run a controller issue |
[eluser]nevsie[/eluser]
Hi All, I am trying to run a simple cron to do a simple task... however i seem to be having a bit of trouble - i think it is how the host is running its "scheduled tasks" as opposed to crons, but you might be able to advise... I am simply running the following: Code: /usr/bin/php /home/sites/domain.com/public_html/index.php my_class my_function Code: /usr/bin/php /home/sites/domain.com/public_html/index.php "my_class my_function" But each time instead of running my function, it is always running the index function for that class - almost like it is ignoring the other variables. Any thoughts on this? EDIT // i do not think the variables are being picked up at all (i.e. my_class my_function) as after turning off defalt routing it fails altogether. guess it is a host issue unless others can advise? Advice is appreciated. N
[eluser]El Coder[/eluser]
Hey, I ran into the same problem and I finally found a solution. The reason lies in the config settings (in application/config/config.php): Code: /* While running your cron, CI does not detect the right URI in order to retrieve the right controller. The solution: http://phpstarter.net/2008/12/run-codeig...-line-ssh/ In short: - build a bootstrap file - define $_SERVER['QUERY_STRING'], $_SERVER['PATH_INFO'] and $_SERVER['REQUEST_URI'] - include CI index.php
[eluser]El Coder[/eluser]
FYI: Code: $this->input->is_cli_request() ... is not working within this process. I used a defined constant instead, as described (see link).
[eluser]joanfihu[/eluser]
http://phpstarter.net/2008/12/run-codeig...-line-ssh/ This has saved me 2 or more hour. Thanks el Coder! Andele!
[eluser]navotjer[/eluser]
In my case, everything was working as expected, except the: Code: $this->input->is_cli_request(); The trick was to fix the input class on line 311: Code: } else { Codeigniter 2.1.4 Best regards!
[eluser]ivantcholakov[/eluser]
Hack 4. Running CodeIgniter from the Command Line, http://net.tutsplus.com/tutorials/php/6-...e-masters/ |
Welcome Guest, Not a member yet? Register Sign In |