0

I prepared a simple task for testing CRON jobs on Amazon EC2:

schedule.rb

set :output, "/home/a/b/current/log/cron_log.log"

 every 5.minutes do
   #command "/usr/bin/some_great_command"
   #runner "MyModel.some_method"
   #rake "some:great:rake:task"
   puts "It's working !!!"
   runner "User.grab_first_user", :environment => 'development'
   runner "User.grab_first_user", :environment => 'production'
 end

user.rb

  def self.grab_first_user
    user = User.first
    puts user.inspect
    if user
      NotificationMailer.send_info(user.email).deliver
    end
  end

notification_mailer.rb <-- this is workin

  def send_info(user_email)
    @user_email = user_email
    mail(:to => 'my@emaill.com', :subject => "[CRON Test]")
  end

When I check the crontab file, I see there this CRON task, but the email is never sent - the method is never called. When I manually call that method, then is everything working (also the email is sent), but the method is never called by CRON.

Am I missing something?

user984621
  • 46,344
  • 73
  • 224
  • 412

1 Answers1

0

Most likely you have not written your tasks into cron.

Have you done bundle exec whenever -w?

It's also possible that the cron daemon isn't started as well.

kenorb
  • 155,785
  • 88
  • 678
  • 743