imalik8088
imalik8088

Reputation: 1631

Whenever gem in rails is not running

I have a cron job for emailing the users in the system and it doesn't want to run. I'm getting the following error message in the log:

rake aborted!
Don't know how to build task 'cron:deliver_email'
/Users/ghost/.rvm/gems/ruby-2.2.1@maalify/bin/ruby_executable_hooks:15:in `eval'
/Users/ghost/.rvm/gems/ruby-2.2.1@maalify/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)

my schedule.rb is looking like that

set :environment, "development"
set :whenever_command, "bundle exec whenever"
set :output, {:error => "log/cron_error_log.log", :standard => "log/cron_log.log"}


every 1.minute do
  command "gem install rake"
  rake 'cron:deliver_email'
end

The stated rake task (rake 'cron:deliver_email') is running correctly if I'm it from the command line with rake cron:deliver_email

I've added whenever to my Gemfile with the not require statement (:require => false).

thats how my cron job is looking like

▶ whenever 
* * * * * /bin/bash -l -c 'gem install rake >> log/cron_log.log 2>> log/cron_error_log.log'

* * * * * /bin/bash -l -c 'cd /Users/ghost/code/IdeaProjects/maalify && RAILS_ENV=development bundle exec rake cron:deliver_email --silent >> log/cron_log.log 2>> log/cron_error_log.log'

## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.

Upvotes: 2

Views: 821

Answers (1)

Yevgeniy Goyfman
Yevgeniy Goyfman

Reputation: 492

You need to tell cron to load rvm environment. See details here:

https://rvm.io/deployment/cron

Upvotes: 1

Related Questions