I want to execute rake sunspot:reindex RAILS_ENV=production command for every four hours. To achieve this i have written simple bash script using shell programming. I will run successfully in terminal but if i tried to run it in crontab then it is not working. Operating system which am using is centos.
Here is my bash script code
#!/bin/bash
#export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH=/usr/local/rvm/gems/ruby-1.9.2-p290/bin:/usr/local/rvm/gems/ruby-1.9.2-p290@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:
echo "started"
cd /var/www/html/spotchase2
pwd
source /usr/local/rvm/environments/ruby-1.9.2-p290
bundle install
if [ "$?" = 0 ]; then
echo `date`
fi
source /usr/local/rvm/environments/ruby-1.9.2-p290
#/usr/local/rvm/gems/ruby-1.9.2-p290/bin/rake sunspot:reindex RAILS_ENV=production
rake sunspot:reindex RAILS_ENV=production
if [ "$?" = 0 ]; then
echo "complete"
fi
Please help me to fix this issue.
EDIT
I am redirecting the output one text file. In that text file am getting only started, bundle install and date. Am not getting complete message, therefore i came to know that it is not working and am not getting any error on that text file.
Please help me to fix this issue.