Finally I could fix this issue. In fact it was not FOSelasticabundle issue, the problem was with the cronjob.
I was running the crontab as below:
#m h dom mon dow command
*/2 * * * * /var/www/Symfony/populateElastica.sh
I found it needs to be redirected the path which the script needs to be run then works perfectly
#m h dom mon dow command
*/2 * * * * cd /var/www/Symfony && /var/www/Symfony/buildAcmeIndex.sh
You need to define the shell script for buildAcmeIndex.sh
as:
#! /bin/sh
echo -------------- Auto Index Started ----------------
/usr/bin/php /var/www/Symfony/app/console fos:elastica:populate --env=prod --no-reset
echo --------------- Auto Index done! -----------------
Just keep in mind to set the path of php as the proper path in Linux server.