我正在使用rails 3并尝试在一定的时间间隔后更新cron作业。当我使用RAILS_ENV =生产rake ts:index时,它工作正常但是sphinx没有使用cron作业索引。为你的解决方案而战。
以下是我的参考代码:
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
我检查了这个命令
sudo tail -f /var/log/syslog |grep CRON
我得到了以下输出,告诉cron作业正在运行
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')
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
提前致谢。