Centos Cronjob中的Cakephp ShellDispatcher错误

Im trying to run a cronjob in Centos with crontab -e, but I can't figure out when the job runs why it does not find any parameters as -app in the ShellDispatcher. I have read Cake PHP Cronjobs and have:

  1. Edited .bashrc and added export PATH="$PATH:/home/phonekar/public_html/app/Console"
  2. Added a cronjob to my useraccount with crontab -e

     53 23 * * * /home/useraccount/public_html/lib/Cake/Console/cakeshell Tracking -cli "/usr/bin" -console "/home/useraccount/public_html/lib/Cake/Console" -app "/home/useraccount/public_html/app" >> /home/useraccount/public_html/tracking.log 2>&1
    

Manually running this command works fine, but when I let the job run i get this error on a loop:

PHP Warning:  array_search() expects parameter 2 to be array, null given in /home/useraccount/public_html/lib/Cake/Console/ShellDispatcher.php on line 320
PHP Warning:  array_splice() expects parameter 1 to be array, null given in /home/useraccount/public_html/lib/Cake/Console/ShellDispatcher.php on line 324

I looked in to the file and it seems like it is expecting the -app value but instead is getting a null value passed to it. I have also verified that the Tracking shell works. Any clarification will help.

Warning: array_splice() expects parameter 1 to be array, null given in ShellDispatcher.php

I hit this error using console of cakephp 2.3.8 but you can encounter this issue on other versions as well. The solution is to edit (command line arguments are not seen) app/Console/cake and on on the line:

exec php -q "$CONSOLE"/cake.php -working "$APP" "$@"

after -q add

-d register_argc_argv=1 

so the line will look like:

exec php -q -d register_argc_argv=1 "$CONSOLE"/cake.php -working "$APP" "$@"

ref: http://www.ecommy.com/programming/cakephp/warning-array_splice-expects-parameter-1-to-be-array-null-given-in-shelldispatcher-php