Reputation: 55
I have written following ruby code in rails application :
every '20 8 1-7 * 4' do
rake 'data_import:check_for_presence_of_file'
end
But above rake task is running ever day at 8:20 am GMT. Is there something wrong with expression ? I have searched internet for cron expression but I have seen conflicting information. Please help.
Upvotes: 0
Views: 174
Reputation: 318
I'm not sure there is a way with cron. '20 8 1-7 * 4' means the first seven days of the month and on thursdays. Instead perhaps do it the first seven days of the month and in rails check if its thursday:
every '20 8 1-7 * *' do
rake 'data_import:check_for_presence_of_file' if Date.today.thursday?
end
Upvotes: 1
Reputation: 6915
This is correct cron schedule for a Tuesday weekly:
20 8 * * 2
Here are more details: https://crontab.guru/#20_8___2
In your sample you are using 1-7
which means every day.
Upvotes: 0