Rails, using whenever gem in development

穿精又带淫゛_ 提交于 2019-11-27 17:36:39

Clear existing cron jobs.

crontab -r

Update cronjob with the environment.

whenever --update-crontab --set environment='development'

You can use the whenever command and its various options to manipulate your crontab.

$ whenever --help
Usage: whenever [options]
    -i [identifier],                 Default: full path to schedule.rb file
        --update-crontab
    -w, --write-crontab [identifier] Default: full path to schedule.rb file
    -c, --clear-crontab [identifier]
    -s, --set [variables]            Example: --set 'environment=staging&path=/my/sweet/path'
    -f, --load-file [schedule file]  Default: config/schedule.rb
    -u, --user [user]                Default: current user
    -k, --cut [lines]                Cut lines from the top of the cronfile
    -v, --version
Sunny
whenever -c cron-name  #removing cronjobs 

Adding following line of code on top of config/schedule.rb worked for me.

 ENV['RAILS_ENV'] = "development"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!