Run job every given time but with delay time using every
mdesantis opened this issue · 5 comments
Hello!
I have a job which should run every 4 hours at minute 30. The cron syntax '30 */4 * * *'
can be used in order to achieve that. But I'm wondering if there is some way to use the every
syntax? Maybe an at
argument could be added to every
, so we could do something like:
scheduler.every '4h', at: '30m' do
# do something every 4 hours at minute 30
end
Thanks!
Hello,
you could write
scheduler.every '4h30m' do
# do something every 4 hours and 30 minutes
end
but that's not what you requesting.
You could do
m30 = Time.now
m30 -= m30.sec
while m30.min != 30; m30 += 60; end
scheduler.every '4h', first_at: m30 do
# do something every 4 hours at minute 30
end
Still doesn't beat the conciseness of #cron
.
Does that help?
Side information: fugit
behind rufus-scheduler has a "natural" module which will get used in rufus-scheduler soon: https://github.com/floraison/fugit#fugitnat
I can imagine something like:
scheduler.schedule('every 4 hours at minute 30') do
# ...
end
that would be equivalent to:
scheduler.cron('30 */4 * * *') do
# ...
end
Hi @jmettraux, thanks for suggestions! I also think that cron syntax is better than that dynamic calculation (cron syntax isn't even bad to me), anyway I think that
scheduler.schedule('every 4 hours at minute 30') do
# ...
end
will be a great addition. But I must say that I'd still prefer something like scheduler.every '4h', at: '30m'
, IMHO it doesn't have neither the obfuscated syntax of cron or the too conversational syntax of 'every 4 hours at minute 30'
Hello,
I think that scheduler.every '4h', at: '30m'
is nice, but what's the pattern? What's the bigger picture? scheduler.every '4M', at: 'first monday 17h30m'
, how can it be generalized? There seems to be a big space behind that door.
Closing the issue but not the conversation.