Aoe_Scheduler
Aoe_Scheduler copied to clipboard
scheduler_cron.sh via cron causes Warning: strpos(): Empty needle in Http.php on line 508 and 514
Hello,
when I run the scheduler_cron.sh direct in bash it runs smooths. But when I run it via crontab I get warnings in system.log:
2016-02-03T13:45:02+00:00 ERR (3): Warning: strpos(): Empty needle in /home/xxx/shop/lib/Zend/Controller/Request/Http.php on line 508 2016-02-03T13:45:02+00:00 ERR (3): Warning: strpos(): Empty needle in /home/xxx/shop/lib/Zend/Controller/Request/Http.php on line 514
seems to be something like this: http://stackoverflow.com/questions/9128488/cron-job-server-issue
https://github.com/AOEpeople/Aoe_Scheduler/issues/212
update:
changes in scheduler_cron.sh seems to fix it:
from: PHP_BIN=$(which php || true) to: PHP_BIN=$(which php-cli || true)
also https://github.com/AOEpeople/Aoe_Scheduler/commit/5cc0cb49e2769fbd64688f859e4c6cd94f1ab29a isn't necessary any more!
Can this be included?
After trying every possible solution I found online (including this above) I still have this warning. I run Magento CE 1.9.1 with all latest patches :-( Warning: strpos(): Empty needle in ../lib/Zend/Controller/Request/Http.php on line 508 Warning: strpos(): Empty needle in ../lib/Zend/Controller/Request/Http.php on line 514 My cron job is: sh /full_path/cron.sh
Just to add a little clarity here. The warning you are seeing is triggered when the Zend_Controller_Request_Http class tries to call setBaseUrl(null)
when in CLI mode. In vanilla Magento, this only ever seems to happen when you call getBaseUrl()
on the class. Without spending a lot of time going through all the core code and all the scheduler code, my guess is that one of the cron jobs you are running is attempting to use a request object when it shouldn't. To help track this down you could look into adding additional logging around the warning handler and perhaps generate a full stack trace.
If you have a proper xdebug setup, you can add a conditional breakpoint to the two location generating the warning. The conditional would be empty($baseUrl)
and should stop program execution in the situation that would generate the warning.
If you get desperate you could edit the lib/Zend/Controller/Request/Http.php file and add a log of the debug backtrace. Something like if(empty($baseUrl)){ error_log(print_r(debug_backtrace(), true)); }
Keep in mind, you should never edit core files. The above suggestion is really just for a debugging situation on a testing server or local install.
Thanks for reply. Both errors appear every 5 minutes when cron runs cron.sh when I switch to cron.php it is OK. This is my exact cron command: sh /home/vp/public_html/my_domain/cron.sh >/dev/null 2>&1 it is running every 5 minutes.
@minc21 making the change in scheduler_cron.sh didn't fix the issue for me, but implementing the change in cron.sh did! 👍
Hi Liam if I may ask you, what changes did you made ?
I changed line 39 in cron.sh at the root of the Magento installation from:
PHP_BIN=which php
to:
PHP_BIN=which php-cli
Hi Liam,
here is the update:
When I changed 14th line from PHP_BIN=which php
to PHP_BIN=which php-cli
my cron job stopped working with no error messages. Jobs were marked as pending. Obviously the warning with empty needle disappeared but the cron wasn't working (one doesn't go without another)
I applied the same change to scheduler_cron.sh but no luck either.
Regards
This is my unchanged cron.sh
#!/bin/sh #location of the php binary if [ ! "$1" = "" ] ; then CRONSCRIPT=$1 else CRONSCRIPT=cron.php fi
MODE="" if [ ! "$2" = "" ] ; then MODE=" $2" fi
PHP_BIN=which php
#absolute path to magento installation
INSTALLDIR=echo $0 | sed 's/cron\.sh//g'
#prepend the intallation path if not given an absolute path
if [ "$INSTALLDIR" != "" -a "expr index $CRONSCRIPT /
" != "1" ];then
if ! ps auxwww | grep "$INSTALLDIR$CRONSCRIPT$MODE" | grep -v grep 1>/dev/null 2>/dev/null ; then
$PHP_BIN $INSTALLDIR$CRONSCRIPT$MODE &
fi
else
if ! ps auxwww | grep "$CRONSCRIPT$MODE" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then
$PHP_BIN $CRONSCRIPT$MODE &
fi
fi
M/k1983,
Liam's line PHP_BIN=which php-cli
might need to be something else...
Check with your hosting company for the name of the php-cli
which is php compiled for the command line.
The php-cli might be compiled with litespeed in mind and named differently.
There might be other reasons it dosen't exist under that name in you path.