如果您了解用于创建 cron 作业的when gem,这个问题可能才有意义。我的 schedule.rb 中有一个任务,例如
every 1.day, :at => '4am' do
command "cd #{RAILS_ROOT} && rake thinking_sphinx:stop RAILS_ENV=#{RAILS_ENV}"
command "cd #{RAILS_ROOT} && rake thinking_sphinx:index RAILS_ENV=#{RAILS_ENV}"
command "cd #{RAILS_ROOT} && rake thinking_sphinx:start RAILS_ENV=#{RAILS_ENV}"
end
但是,当我使用更新我的 crontab 时
whenever --update-crontab appname --set environment=production
cron 作业仍然有 RAILS_ENV=development。我现在的生产和开发任务是一样的,我只需要改变环境变量,因为thinking_sphinx需要知道当前的环境。关于如何做到这一点的任何想法?
谢谢!