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

Run multiple independent Jobs sequentially #391

Open
emilhakobian opened this issue May 8, 2021 · 0 comments
Open

Run multiple independent Jobs sequentially #391

emilhakobian opened this issue May 8, 2021 · 0 comments

Comments

@emilhakobian
Copy link

emilhakobian commented May 8, 2021

I'm trying to execute multiple jobs sequentially with the following order 1st -> 2nd -> 3rd.
One condition is mandatory: each next job must run after the previous completion.
I've tried chain also an example from chain_test.go, but no success

`func init() {
var j1, j2,j3 countJob
j1.name = "first"
j2.name = "second"
j3.name = "third"

j1.delay = 120 * time.Second
j2.delay = 15 * time.Second
    j3.delay = 10 * time.Second

chain := cron.NewChain(cron.DelayIfStillRunning(cron.DiscardLogger))
wrappedJob1 := chain.Then(&j1)
wrappedJob2 := chain.Then(&j2)
wrappedJob3 := chain.Then(&j3)

c := cron.New(cron.WithChain(cron.DelayIfStillRunning(cron.DefaultLogger)))
c.AddJob("05 11 * * *", wrappedJob1)
c.AddJob("06 11 * * *", wrappedJob2)
c.AddJob("08 11 * * *", wrappedJob2)

c.Start()

}
`

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

1 participant