Rails 的 cronjob - 每当 gem 不执行任何操作时,为什么? (开发模式)

发布于 2024-11-19 01:31:33 字数 1883 浏览 0 评论 0原文

我试图每晚自动备份我的数据库。我想使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文