【发布时间】:2011-04-25 02:21:05
【问题描述】:
我以前没有使用过 cron,所以我不能确定我做对了。我想要自动化的任务似乎没有运行。我在终端中执行了这些步骤:
- sudo gem 随时安装
- 切换到应用目录
- 无论何时。 (这创建了文件 schedule.rb)
-
我将此代码添加到 schedule.rb:
every 10.minutes do runner "User.vote", environment => "development" end every :hour do runner "Digest.rss", :environment => "development" end -
我将此代码添加到 deploy.rb:
after "deploy:symlink", "deploy:update_crontab" namespace :deploy do desc "Update the crontab file" task :update_crontab, :roles => :db do run "cd #{current_path} && whenever --update-crontab #{application}" end end 我在终端中这样做了:无论何时
-
它返回:
@hourly cd /Users/RedApple/S && script/runner -e development 'Digest.rss' 0,10,20,30,40,50 * * * * cd /Users/RedApple/S && script/runner -e development 'User.vote' -
在终端中单独运行这些命令可以:
script/runner -e development 'Digest.rss' script/runner -e development 'User.vote' 现在以开发模式运行本地服务器,脚本/服务器,我没有看到任何证据表明代码实际上正在运行。有没有我没有做的步骤? “无论何时”的指南都没有显示除我所做的以外的任何其他内容。
【问题讨论】: