I have the following task defined in my schedule.rb that should be run every 1st of the month a 2am.
every "0 2 1 * *" do
rake ":task_1"
end
What I really want to do though is run that task every fourth sunday instead. All I found in the whenever
gem-documentation was something like every :sunday, :at => '2am'
. How would this look if I wanted to run the task every fourth sunday at 2am?
It's not possible to achieve such result with the crontab syntax. There are some workarounds.
The most common is to configure it to run every day for the first 7 days of the month, and at the top of the script exist if it's not Sunday.
Quoting Run every 2nd and 4th Saturday of the month
You can easily accomplish it with whenever. Configure the cron as indicated, then in the rake task check and exit from the task if the day is not Sunday