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

possibility to perform a schedule from HH:MM till HH:MM ? #68

Open
vi7Ch opened this issue Mar 5, 2019 · 5 comments
Open

possibility to perform a schedule from HH:MM till HH:MM ? #68

vi7Ch opened this issue Mar 5, 2019 · 5 comments

Comments

@vi7Ch
Copy link

vi7Ch commented Mar 5, 2019

Hi,

Do you know whether it would be possible to include a from HH:MM till HH:MM feature ?
Let's say I want to schedule a task every 5MIN from Monday to Friday, from 8:00 till 18:30.

maybe with a
gocron.Clear()

<- gocron.Start()

That would be a good feature if it is currently not possible.

Any idea ?

Thanks,

@ngethe
Copy link

ngethe commented Apr 27, 2019

I think you can do
gocron.Every(1).Day().At("8:00").Do(task_start)
to start the task

gocron.Every(1).Day().At("18:30").Do(task_stop)
to stop the task

@neuyilan
Copy link

I think you can do
gocron.Every(1).Day().At("8:00").Do(task_start)
to start the task

gocron.Every(1).Day().At("18:30").Do(task_stop)
to stop the task

LGTM, prefect!

@iambudi
Copy link

iambudi commented Dec 11, 2019

I think you can do
gocron.Every(1).Day().At("8:00").Do(task_start)
to start the task

gocron.Every(1).Day().At("18:30").Do(task_stop)
to stop the task

How to run it Every 5 Minutes? It only run once at 8:00?

@JohnRoesler
Copy link
Contributor

Expanding on the example - this works:

package main

import (
	"log"

	"github.com/jasonlvhit/gocron"
)

func task() {
	log.Println("I am runnning task.")
}

func task_start() {
	log.Println("Starting the task.")
	gocron.Every(5).Minutes().From(gocron.NextTick()).Do(task)
}

func task_stop() {
	log.Println("Stopping the task.")
	gocron.Remove(task)
}

func main() {
	gocron.Every(1).Day().At("08:00").Do(task_start)
	gocron.Every(1).Day().At("18:30").Do(task_stop)
	<-gocron.Start()
}

@iambudi
Copy link

iambudi commented Dec 12, 2019

@JohnRoesler Perfect! thanks.

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

No branches or pull requests

6 participants