Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] ability to immediately start an @every job #406

Open
wsw70 opened this issue Aug 11, 2021 · 2 comments
Open

[feature] ability to immediately start an @every job #406

wsw70 opened this issue Aug 11, 2021 · 2 comments

Comments

@wsw70
Copy link

wsw70 commented Aug 11, 2021

Would it be possible to add an option to start jobs scheduled as @every immediately (and not after the interval)?

The docs mention that

For example, "@every 1h30m10s" would indicate a schedule that activates after 1 hour, 30 minutes, 10 seconds, and then every interval after that.

I believe that there it would be interesting to have the immediate start - for instance, I need to do

googleCalendar()
forecast()
temperature()
c := cron.New()
c.AddFunc("@every 1min", googleCalendar)
c.AddFunc("@every 15min", forecast)
c.AddFunc("@every 12min", temperature)
c.Start()

instead of, say

c := cron.New({intervalRunAtStartup: true})
c.AddFunc("@every 1min", googleCalendar)
c.AddFunc("@every 15min", forecast)
c.AddFunc("@every 12min", temperature)
c.Start()

(see also #396)

@ivanjaros
Copy link

you can do this by simply calling Run() on every job when you are calling Start() on cron. since you have to provide the jobs to the cron, you already have access to them so calling Run() is not a problem.

@zeewell
Copy link

zeewell commented Apr 22, 2022

#436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants