1

I am using whenever gem and I have written a rake task to send emails. In my schedule.rb when I use this code

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

every :day, :at => '11:20pm' do 
  rake "send_daily_reports"
end

I am not getting mails but when i use something like this

every 5.minutes do
  rake "send_daily_reports"
end

I get mails for 5 every minutes.

I tried replacing

every :day

with

every 1.day

but still its not working. I have followed every step. When I pull the code into the cloud I use the command

whenever -w

to update the crontab and then restart the server. I thought that there might be an issue with the linux system time.But when i used the date command in the terminal I got the correct date and time.I also checked the cron_error log but there are no errors logged. Can anyone please help me out here?

Nikhil Gopinath
  • 170
  • 1
  • 12
  • what does `crontab -l` report? – Jim Van Fleet Apr 13 '16 at 18:30
  • What does send_daily_reports look like? Is it possible that there is some kind of time zone issue that prevents send_daily_reports from having any data to report on at 11:20pm? – msergeant Apr 13 '16 at 18:50
  • 1
    @msergeant I recieved the mail at 4.20 am when the time set was "11.20pm". So I guess there was an error with the timezone setting in linux. I changed the timezone and now its working. Previously the default timezone was in utc and i thought the system would automatically set itself according to the timezone. Once I changed the time zone it is working now. – Nikhil Gopinath Apr 14 '16 at 05:02

1 Answers1

2

I recieved the mail at 4.20 am when the time set was 11.20 pm. So I guess timezone setting was set to utc default in amazon linux.

I changed the timezone and now its working and I referred this link http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html

Previously the default timezone was in utc and I thought the system would automatically set itself according to the timezone. Once I changed the time zone it is working now.

Shiva
  • 11,485
  • 2
  • 67
  • 84
Nikhil Gopinath
  • 170
  • 1
  • 12