schedule
schedule copied to clipboard
How to run on ecery xth Minute
Hi, i want to run my code on every 5th minute like: 00:05, 00:10, 00:15, 00:20...
But now when i am defining like:
schedule.every(5).minutes.do(
Something like */5 * * * * in cron..!! is it possible??
It may be clunky, but have you looked at using .at?
you would have to use it several times but you could do schedule.every().hour.at(':05').do() schedule.every().hour.at(':10').do() schedule.every().hour.at(':15').do()
It would be sweet if at accepted an array. schedule.every().hour.at([':05',':10',..,':55']) Or, it just looked at @args and scheduled them all
I created a simple snippet for this in case anyone is interested
def schedule_every(f, *, minute=5):
"""
Creates a schedule similar to cron
*/5 * * * *
"""
for i in range(minute, 60, minute):
schedule.every().hour.at(f":{i:02d}").do(f)
schedule_every(job, minute=5)