I would like to create a cron job that triggers at 23h59, then 3h59, 7h59, 11h59…
My solution
scheduler.add_job(
func=myfunc,
trigger="cron",
day='*',
hour="*/4",
minute=59,
second=0,
)
works but triggers every time one hour too late: 00.59, 4.59…
Any solution please?
2
You are using APScheduler. You can do
scheduler.add_job(
func=myfunc,
trigger="cron",
day='*',
hour="3-23/4",
minute=59,
second=0,
)
Check the scheduled times here
You can use 1/4
instead of */4
if you want it to run on specific hours rather than a specific period. The crontab expression syntax for this would be 59 1/4 * * *
. Keep in mind that this syntax is not standard, and may not work in all cron implementations