6

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

Shiva Verma
  • 89
  • 2
  • 9

1 Answers1

10

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.

Gabor Lengyel
  • 14,129
  • 4
  • 32
  • 59
  • 3
    The only thing that's hard to do with a cron but easy with an interval is to create a job that runs every X minutes *starting now*. – Rob Watts Oct 23 '17 at 17:00
  • You can do some things with interval that you can't with (most implementations of) cron, for example run every 25 minutes. You can specify the ticks of a minute/date/month..etc to run in cron, but you can't specify the gap between runs. – yelsayed May 25 '18 at 02:09