Rails 的 cronjob - 每当 gem 不执行任何操作时,为什么? (开发模式)
我试图每晚自动备份我的数据库。我想使用 gem 并且我的应用程序仍在开发环境中运行。
我在应用程序文件夹中使用 wheneverize .
命令创建 config/schedule.rb
文件,swhcih 如下所示:
set :output, "/User/eveadmin/rails/feebacker/log/cron_log.log"
set :environment, "development"
every 1.day, :at => '2:30 am' do
dump_path = "/User/eveadmin/rails/db_backups/dump#{Date.today.to_s}"
command "sudo mysqldump -u user -p secretpasswort feedbacker_development > #{dump_path}.sql"
command "tar -zcvf #{dump_path}.tar.gz #{dump_path}.sql"
command "rm #{dump_path}.sql"
runner "Storage.store_dump '#{dump_path}.tar.gz'"
end
将其部署到我的服务器后,当前也在开发中运行模式下,我使用了命令
whenever --update-crontab feedbacker --set environment=development
After this 我的 crontab 看起来如下所示:
# Begin Whenever generated tasks for: feedbacker
30 2 * * * /bin/bash -l -c 'sudo mysqldump -uroot -prootz feedbacker_development > /User/eveadmin/rails/db_backups/dump2011-07-07.sql >> /User/eveadmin/rails/feebacker/log/cron_log.log 2>&1'
30 2 * * * /bin/bash -l -c 'tar -zcvf /User/eveadmin/rails/db_backups/dump2011-07-07.tar.gz /User/eveadmin/rails/db_backups/dump2011-07-07.sql >> /User/eveadmin/rails/feebacker/log/cron_log.log 2>&1'
30 2 * * * /bin/bash -l -c 'rm /User/eveadmin/rails/db_backups/dump2011-07-07.sql >> /User/eveadmin/rails/feebacker/log/cron_log.log 2>&1'
30 2 * * * /bin/bash -l -c 'cd /Users/thomasmaximini/Sites/rails_projekte/feedbacker && script/rails runner -e development '\''Storage.store_dump '\''\'\'''\''/User/eveadmin/rails/db_backups/dump2011-07-07.tar.gz'\''\'\'''\'''\'' >> /User/eveadmin/rails/feebacker/log/cron_log.log 2>&1'
# End Whenever generated tasks for: feedbacker
它什么也不做,没有生成 cron.log,没有完成备份,什么也没有。所以我不知道我做错了什么,因为没有引发调试错误。我希望有人能帮忙,谢谢。
I am trying to auto backup my database every night. I want to use the whenever gem and my application runs still in development environment.
i used wheneverize .
command in my app folder to create the config/schedule.rb
file, swhcih looks like this:
set :output, "/User/eveadmin/rails/feebacker/log/cron_log.log"
set :environment, "development"
every 1.day, :at => '2:30 am' do
dump_path = "/User/eveadmin/rails/db_backups/dump#{Date.today.to_s}"
command "sudo mysqldump -u user -p secretpasswort feedbacker_development > #{dump_path}.sql"
command "tar -zcvf #{dump_path}.tar.gz #{dump_path}.sql"
command "rm #{dump_path}.sql"
runner "Storage.store_dump '#{dump_path}.tar.gz'"
end
After deploying it to my server, also currently running in development mode, I used the command
whenever --update-crontab feedbacker --set environment=development
After this my crontab looks like the following:
# Begin Whenever generated tasks for: feedbacker
30 2 * * * /bin/bash -l -c 'sudo mysqldump -uroot -prootz feedbacker_development > /User/eveadmin/rails/db_backups/dump2011-07-07.sql >> /User/eveadmin/rails/feebacker/log/cron_log.log 2>&1'
30 2 * * * /bin/bash -l -c 'tar -zcvf /User/eveadmin/rails/db_backups/dump2011-07-07.tar.gz /User/eveadmin/rails/db_backups/dump2011-07-07.sql >> /User/eveadmin/rails/feebacker/log/cron_log.log 2>&1'
30 2 * * * /bin/bash -l -c 'rm /User/eveadmin/rails/db_backups/dump2011-07-07.sql >> /User/eveadmin/rails/feebacker/log/cron_log.log 2>&1'
30 2 * * * /bin/bash -l -c 'cd /Users/thomasmaximini/Sites/rails_projekte/feedbacker && script/rails runner -e development '\''Storage.store_dump '\''\'\'''\''/User/eveadmin/rails/db_backups/dump2011-07-07.tar.gz'\''\'\'''\'''\'' >> /User/eveadmin/rails/feebacker/log/cron_log.log 2>&1'
# End Whenever generated tasks for: feedbacker
It simply does nothing, no cron.log is generated, no backups are done, nothing. So I dont know what I am doing wrong as there are no errors raised to debug. I hope anybody can help, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论