2

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.
imalik8088
  • 1,501
  • 5
  • 21
  • 39

1 Answers1

1

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

https://rvm.io/deployment/cron

  • And how about rbenv in production. because im using rbenv in production. – imalik8088 Jan 12 '16 at 09:27
  • The error output you posted suggests that `rvm` is being used. You should try not to use different tools between your environments. Anyhow, for `rbenv` see this answer: http://stackoverflow.com/questions/8434922/ruby-script-using-rbenv-in-cron – Yevgeniy Goyfman Jan 12 '16 at 14:51