/schedule.rb Secret
Last active
September 12, 2019 18:16
Star
You must be signed in to star a gist
config/schedule.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/schedule.rb | |
# Send daily sales report at 9:00 am everyday. | |
every 1.day, at: '9:00 am' do | |
rake 'send_daily_sales_report' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to run the cron in 10 to 7 IST timings. | |
every 1.hour, at: ['4:30 am', '5:30 am', '6:30 am', '7:30 am', '8:30 am', '9:30 am', '10:30 am', '11:30 am', '12:30 pm', '1:30 pm'] do | |
runner 'UtilitiesService.clean_logs()' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert IST to UTC and return array of UTC time like ['2:30 am', '3:30 am',...] | |
def to_utc(*time) | |
begin | |
time.collect{ |t| ActiveSupport::TimeZone.new('Mumbai').local_to_utc(Time.parse(t)).strftime('%l:%M %P').strip } | |
rescue Exception => e | |
Rails.logger.info "Error: #{e.message}" | |
Rails.logger.info "Backtrace: #{e.backtrace}" | |
end | |
end | |
# to run the cron in 10 to 7 IST timings. | |
every 1.hour, at: to_utc('10:00 am', '11:00 am', '12:00 pm', '1:00 pm', '2:00 pm', '3:00 pm', '4:00 pm', '5:00 pm', '6:00 pm', '7:00 pm') do | |
runner 'UtilitiesService.clean_logs()' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment