Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between 'Interval' and 'Cron' triggers in APScheduler?

I am using APScheduler for my project. I went through APScheduler documentation. But I am not able to understand what is actual difference between 'Interval' and 'cron' triggers. Following definition was given in docs:

interval: use when you want to run the job at fixed intervals of time

cron: use when you want to run the job periodically at certain time(s) of day

like image 292
Shiva Verma Avatar asked Mar 08 '23 20:03

Shiva Verma


1 Answers

With interval, you can specify that the job should run say every 15 minutes. A fixed amount of time between each run and that's it.

With cron, you can tell it to run on every second tuesday at 9am, or every day at noon, or on every 1st of January at 7pm. In cron, you define the minute, hour, day of month, month, day of week (eg. Monday) and year where it should run, and you can assign periodicity to any of those (ie. every Monday, or every fifth minute).

Anything you can achieve with interval can also be achieved with cron I think, but not the other way around.

like image 50
Gabor Lengyel Avatar answered May 14 '23 12:05

Gabor Lengyel