15

SOLVED: Crap... why is it always you figure something out right AFTER you finally decided to ask for help!!

If anyone else is having this problem, try running from /usr/local/bin/php instead of /usr/bin/php to get codeigniter to pick up on the URI segments.

QUESTION

I have the latest installation of codeigniter and everything seems to be working fine locally. I recently put my files on my server and everything except my cron command is working.

When I try to call a controller through cron (as described here: http://codeigniter.com/user_guide/general/cli.html), I am not getting the controller. Instead, the output I get is simply my default controller (login page).

This worked fine locally and the index.php IS getting called because I'm getting emailed the output from the default page.

Someone asked a similar question here: CodeIgniter Cron Job on Shared Hosting? Responders suggested that it was a problem with Cpanel (which is what i'm now trying to use to set up the cron job), but talking to my hosting provider, they said the whole command is being run. Nevertheless, CI isn't grabbing the URI for the controller. I also checked to make sure the base_url is set correctly (which is proven by the file working fine through a URL call).

Any thoughts? I just can't seem to figure out why it's not grabbing the URI when in command line format: /usr/bin/php index.php controller_class method

Community
  • 1
  • 1
MikeCruz13
  • 1,254
  • 1
  • 10
  • 19

4 Answers4

19

This was the answer:

Use /usr/local/bin/php instead of /usr/bin/php to get codeigniter to pick up on the URI segments.

Jakub
  • 20,418
  • 8
  • 65
  • 92
MikeCruz13
  • 1,254
  • 1
  • 10
  • 19
  • awesome - this is great! solved my EXACT problem - thanks so much – Laurence Jul 22 '12 at 08:01
  • Thanks! To save a step for those encountering this for the first time, the full syntax for the Command would be something like: /usr/local/bin/php /home/mydomainusername/public_html/index.php controller method – mpemburn Dec 03 '13 at 15:12
  • thak you is it picking up the file finally but I get ```Could not open input file```for the index.php file – gepex Apr 25 '20 at 19:41
1

Here is solution first you need to find path from phpinfo document_root path

php5 /home/abc/public_html/index.php folder_name controller_name function_name

It's 100% working

0

I'm glad you got it working Mike. I ran into similar problems and ended up using the CI Cron Job Bootstrapper on a recent project that was running on a cPanel host. I'm just posting this incase it helps someone else.

jljohnstone
  • 1,202
  • 1
  • 10
  • 14
0

For me this is what worked:

php54 -f /home/{cpanel_user}/public_html/index.php controller function
Unsparing
  • 6,985
  • 2
  • 17
  • 33
  • While this code may answer the question, it would be better to include some context, explaining how it works and when to use it. Code-only answers are not useful in the long run. – Bono Nov 27 '15 at 22:23