1

I am trying to call a Codeigniter controller through a cron job. But something is going wrong, I am not getting the desired result. I tried to access the same controller through the PHP CLI and instead of returning the output that the controller should return, it outputs the contents of the project homepage. This question has a similar problem.

My crontab has the following entry:

22 13 * * * php /var/www/html/projectfolder/index.php cronJobGmutrrPdt runJobForUpdatingClgRevConnSummary

But this is not working, so I tried to run it through the CLI:

php /var/www/html/projectfolder/index.php cronJobGmutrrPdt runJobForUpdatingClgRevConnSummary

In this case the CLI runs but instead of outputting the controller's output it outputs the contents of the default controller that is the project homepage.

Community
  • 1
  • 1
Om Shanker
  • 49
  • 2
  • 15
  • What controller are you calling? It seems you are just requesting index.php and in that case it would not be strange that you get a output of the standard controller. Have you tried `/var/www/html/projectfolder/index.php/mycontroller/method/` ?(try this with the cli first) – g_uint Apr 22 '15 at 08:08
  • "cronJobGmutrrPdt" is the controller and "runJobForUpdatingClgRevConnSummary" is the function – Om Shanker Apr 22 '15 at 11:32

2 Answers2

0

Most likely you have register_argc_argv disabled in your php.ini file. This is why the direct php script works. Since a cronjob runs like a CLI command you will need this enabled to pass arguments.

http://php.net/manual/en/reserved.variables.argv.php

Take a look at this php document above and it should lead you in the right direction.

Siniseus
  • 121
  • 6
  • Did it but sad to say it didn't help me. Same result getting homepage as output instead of the controller i called P.S i added register_argc_argv in the php.ini that is at location /etc/php5/cli/php.ini and not in apache2 and cgi folders, Is it correct or shall it be somewhere else – Om Shanker Apr 22 '15 at 07:57
0

for me this worked:

/usr/bin/php  -f /var/www/html/projectfolder/index.php mycontroller method