Rails 3 和 crontab - Crontab 日志为空
每当我的 ruby on Rails 应用程序中我都实现了 gem。这个 gem 生成了配置文件,我在那里有这样的数据:
config/schedule.rb
set :output, "/vol/www/apps/logs/cron_log.log" #Log for production.
set :my_path, "/vol/www/apps/ror_tutorial/current"
every 5.minutes do
command "cd #{my_path} && bundle exec rake thinking_sphinx:index RAILS_ENV=production && bundle exec rake thinking_sphinx:rebuild RAILS_ENV=production && chmod 777 -R #{my_path}/log"
end
因此,这会在 crontab 中生成这样的代码:
$ crontab -e
# Begin Whenever generated tasks for: ror_tutorial
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /vol/www/apps/ror_tutorial/current && bundle exec rake thinking_sphinx:index RAILS_ENV=production && bundle exec rake thinking_sphinx:rebuild RAILS_ENV=production && chmod 777 -R /vol/www/apps/ror_tutorial/current/log >> /vol/www/apps/logs/cron_log.log 2>&1'
# End Whenever generated tasks for: ror_tutorial
Everuthing 可以工作,但我的 cron_log.log 是空的。为什么?我该如何解决这个问题?
I implemented gem whenever in my ruby on rails app. This gem generated config file and i have such data there:
config/schedule.rb
set :output, "/vol/www/apps/logs/cron_log.log" #Log for production.
set :my_path, "/vol/www/apps/ror_tutorial/current"
every 5.minutes do
command "cd #{my_path} && bundle exec rake thinking_sphinx:index RAILS_ENV=production && bundle exec rake thinking_sphinx:rebuild RAILS_ENV=production && chmod 777 -R #{my_path}/log"
end
So this generates such code in crontab:
$ crontab -e
# Begin Whenever generated tasks for: ror_tutorial
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /vol/www/apps/ror_tutorial/current && bundle exec rake thinking_sphinx:index RAILS_ENV=production && bundle exec rake thinking_sphinx:rebuild RAILS_ENV=production && chmod 777 -R /vol/www/apps/ror_tutorial/current/log >> /vol/www/apps/logs/cron_log.log 2>&1'
# End Whenever generated tasks for: ror_tutorial
Everuthing works but my cron_log.log is empty. Why? How can i fix that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 crond 是在哪里启动的。日志记录级别可能已关闭。 这篇文章很好地解释了这一点。
Check out where crond is being started. The logging level may be turned off. This post here explains it fairly well.