cron icon indicating copy to clipboard operation
cron copied to clipboard

Support @reboot

Open fanzhao1986 opened this issue 4 years ago • 3 comments

Hi, do you have any plan to support non-standard case @reboot, here I mean trigger a call back when invoke cron.Start() method to run the cron goroutine. This may help user to fire an event (call back) in the cron goroutine. If user wants to run some methods based on the time.Time now in the cron.Cron.Run() method before running schedule timer. This can help. Without it, it is not easier to implement codes want to sync time.Time NOW with the cron goroutine. This may be very critical in some case.

fanzhao1986 avatar Nov 25 '20 00:11 fanzhao1986

You can simply run your functions before invoking cron.Start() to emulate @reboot, no?

ivanduka avatar Mar 22 '21 23:03 ivanduka

I would like this library to match https://en.wikipedia.org/wiki/Cron ... and it DOES look like @reboot is mentioned there. I must have missed it, or I didn't draw the connection to running it on Start(), since that's not necessarily on reboot.

Although the workaround exists and is not too onerous, this has come up enough that it's probably worth adding..

robfig avatar Oct 01 '21 20:10 robfig

Actually.. I'm not sure about this. It seems like the distinction between a real reboot is important to make it much more useful.

The workaround is actually easier than using this schedule 😆

myFunc()

vs

c.AddFunc("@reboot", myFunc) 

What am I missing?

robfig avatar Oct 01 '21 21:10 robfig