Skip to content

feat: support for running immediately#436

Open
zeewell wants to merge 1 commit into
robfig:masterfrom
zeewell:feature/immediately_run
Open

feat: support for running immediately#436
zeewell wants to merge 1 commit into
robfig:masterfrom
zeewell:feature/immediately_run

Conversation

@zeewell

@zeewell zeewell commented Jan 17, 2022

Copy link
Copy Markdown

No description provided.

@zeewell zeewell changed the title feat: supports running job immediately feat: support for running immediately Jan 17, 2022
@mxAge18

mxAge18 commented Apr 2, 2022

Copy link
Copy Markdown

@robfig this feature is usefull, please supoort this, cheers

@ryjogo

ryjogo commented Apr 20, 2022

Copy link
Copy Markdown

Agreed, this is a good feature to have.

@alaingilbert

alaingilbert commented Apr 19, 2025

Copy link
Copy Markdown

@zeewell @mxAge18 @ryjogo I made a fork that addresses almost all issues of this repo.
https://github.com/alaingilbert/cron

If you want to run a specific job at a random place in your code ->

c := cron.New()
id, _ := c.AddJob("* * * * *", func() {
	fmt.Println("hello world")
})
c.Start()
// ...
c.RunNow(id)

Or if you want to run the job when the cron starts ->

_, _ = c.AddJob("*/10 * * * * *", func() {
	fmt.Println("this job runs as soon as cron is started, then at every 10th seconds", time.Now())
}, cron.RunOnStart)

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

Successfully merging this pull request may close these issues.

4 participants