【问题标题】:How to test cronjob in ruby on rails in ubuntu如何在 ubuntu 的 ruby​​ on rails 中测试 cronjob
【发布时间】:2015-11-08 12:27:45
【问题描述】:

我在 ruby​​ on rails 中创建了一个 cronjob,使用时使用 gem 并在 schedule.rb 中编写代码

set :output, {:error => "log/cron_error_log.log", :standard => "log/cron_log.log"}
 every '* * * * * ' do
   command "puts 'you can use raw cron syntax too'"
 end

之后我通过命令更新我的 crontab

whenever --update-crontab

然后重启

sudo service cron restart

并通过crontab -l检查

每当生成任务时开始:/home/haseebahmad/projects/social/config/schedule.rb * * * * * /bin/bash -l -c 'puts '\''你也可以使用原始的cron语法'\'' >> log/cron_log.log 2>> log/cron_error_log.log'

结束每当为:/home/haseebahmad/projects/social/config/schedule.rb 生成任务时

但它不起作用意味着 cronjo 不起作用。如何测试?

【问题讨论】:

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


    【解决方案1】:

    您可以通过以下方式运行您的 cron 作业, 红宝石/home/haseebahmad/projects/social/config/schedule

    【讨论】:

    • 您是否以 root 身份登录,并且您已经进入 /home/haseebahmad/projects/social/config/ 目录并运行 ruby​​ schedule
    • 只有一件事,错误来自 /home/haseebahmad/projects/social/config/schedule.rb:第 17 行:每个:找不到命令 /home/haseebahmad/projects/social/config/schedule .rb:第 18 行:输入“你也可以使用原始 cron 语法”:找不到命令 /home/haseebahmad/projects/social/config/schedule.rb:第 20 行:结束:找不到命令
    猜你喜欢
    • 2015-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多