Reputation: 170
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?
Upvotes: 1
Views: 227
Reputation: 170
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.
Upvotes: 2