When using the whenever
gem we can set a monthly job like this :
every :month do
...
end
Will this run the job at the end of the month or at the start of the month? I want to run it at the end.
When using the whenever
gem we can set a monthly job like this :
every :month do
...
end
Will this run the job at the end of the month or at the start of the month? I want to run it at the end.
From the tests in whenever repo:
assert_equal '0 0 1 * *', parse_time(:month)
So :month
will generate a cron entry that looks like 0 0 1 * *..
This corresponds to run once a month at midnight of the first day of the month.
One way to make the job run last day of the month would be to use the raw cron entry in wherever as follows:
every '0 0 L * *' do
...
end
This assumes that the cron on the server supports the L
flag for representing the last day of the month.
See Cron job to run on the last day of the month for more about running a cron job on the last day of the month.
© 2022 - 2024 — McMap. All rights reserved.