I am using whenever gem to schedule jobs but I am not able to figure out how to schedule a job for the end of each month. Below is the which I want to run at the end of each month.
schedule.rb
every 1.month, at: 'end of the month at 5am' do
rake 'update_user', environment: ENV['RAILS_ENV']
end
Please help me fix this
Last day of the month is tricky in a cron job but you could use raw cron syntax to specify start of each month to run a job as follows:
The syntax is minute, hour, day of month, month, day of week.
If running the job at the start of the month isn't an option, you could schedule the job run daily on the 28th-31st day each month and add logic in your take to only execute the job on the last day of each month as described in this answer