【问题标题】:Whenever Gem and cron Job每当 Gem 和 cron 作业
【发布时间】:2016-02-07 19:37:13
【问题描述】:

我遵循了每当 gems 网站上的说明,并尝试在服务器上的开发和生产模式下都遵循它。

set :output, "/file/to/path/cron.log"
every 1.day, at: '11:59 pm' do
   command "sudo touch /file/to/path"
   runner "Location.transfer_data",:environment => 'production' 
end

它不会创建文件(这是一个测试,因为我没有生产数据)。

我花了几个小时尝试调试它,crontab -l 给了我这个输出

59 23 * * * /bin/bash -l -c 'sudo touch /file/to/path >> /file/to/path/cron.log 2>&1'

59 23 * * * /bin/bash -l -c 'cd /var/www/name && script/rails runner -e production '\''Location.transfer_data'\'' >> /file/to/path/cron.log 2>&1'

问候,

巴巴尔·雷曼

【问题讨论】:

  • 我现在如何编辑它?
  • @Babar 你检查了log infotransfer_data 的写法吗??
  • 我使用了 Rails 控制台日志记录,但也没有显示在日志文件中。

标签: ruby-on-rails ruby linux bash cron


【解决方案1】:

我解决了这个问题,不知道具体是哪一个解决了它,但这些是我采取的步骤

  1. whenever --update-cron 命令添加了作业名称

whenever --update-cron jobName

  1. 重新启动cron服务

sudo service cron restart

  1. 授予对日志文件的完全访问权限

sudo chmod 777 /path/to/file.log

希望对其他人有用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多