cron icon indicating copy to clipboard operation
cron copied to clipboard

The difference between cron.New() and cron.New(cron.WithSeconds()) ?

Open Kevin-free opened this issue 3 years ago • 1 comments

illustrate: I know that cron.New() doesn't support seconds, but cron.New(cron.WithSeconds()) does. question: What I'm curious about is what are the pros and cons between the two? Is there a difference in performance? thanks~

Kevin-free avatar Jun 22 '22 08:06 Kevin-free

There is no difference in performance using these two options, I guess. If we look under the hood, we will see, that it uses *time.Timer in both cases.

Option cron.WithSeconds() allows you to use seconds in your cron scheduling parameter. The main difference between these two options is that the classic format of cron contents only 5 fields: (minute hour day_of_the_month month day_of_the_week). On the other hand, it is sometimes useful to run your job at the certain second, and option cron.WithSeconds() allows you to do it (format is (second minute hour day_of_the_month month day_of_the_week)).

pmokeev avatar Aug 03 '23 12:08 pmokeev