I am using rails 3 and trying to update cron job after certain time interval. When I used RAILS_ENV=production rake ts:index, it is working fine but sphinx is not indexing with cron job. Wating for your solution.
Below are my codes for your reference:
gem 'whenever', :require => false
schedule.rb
set :output, "/var/www/somesitename.com/public_html/current/log/cron_log.log"
set :environment, "production"
every 1.minutes do
rake "ts:rebuild RAILS_ENV=production"
end
I check this command
sudo tail -f /var/log/syslog |grep CRON
and i got following output which tell cron job is running
May 22 16:40:01 anveshna /USR/SBIN/CRON[31133]: (shivraj) CMD (/bin/bash -l -c 'cd /var/www/xproject/public_html/releases/20140522093026 && RAILS_ENV=production bundle exec rake ts:rebuild RAILS_ENV=production --silent >> /var/www/demo.anveshnatech.com/public_html/current/log/cron_log.log 2>&1')
May 22 16:40:01 anveshna /USR/SBIN/CRON[31134]: (shivraj) CMD (/bin/bash -l -c 'cd /var/www/xproject/public_html/releases/20140522093026 && RAILS_ENV=production bundle exec rake ts:rebuild RAILS_ENV=production --silent >> /var/www/demo.anveshnatech.com/public_html/current/log/cron_log.log 2>&1')
output of crontab -e
# Begin Whenever generated tasks for: /var/www/xproject/public_html
* * * * * /bin/bash -l -c 'cd /var/www/xproject/public_html/releases/20140522093026 && RAILS_ENV=production bundle exec rake ts:rebuild RAILS_EN$
# End Whenever generated tasks for: /var/www/xproject/public_html
# Begin Whenever generated tasks for: /var/www/xproject/public_html/releases/20140521084223/config/schedule.rb
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c 'cd /var/www/xproject/public_html/r$
# End Whenever generated tasks for: /var/www/xproject/public_html/releases/20140521084223/config/schedule.rb
# Begin Whenever generated tasks for: /var/www/xproject/public_html/releases/20140522093026/config/schedule.rb
* * * * * /bin/bash -l -c 'cd /var/www/xproject/public_html/releases/20140522093026 && RAILS_ENV=production bundle exec rake ts:rebuild RAILS_EN$
# End Whenever generated tasks for: /var/www/xproject/public_html/releases/20140522093026/config/schedule.rb
Thanks in advance.