Run code once an hour: react whenever Supply.interval(60 * 60) { say "it's been an hour" }
Right now that gets about 0.01 seconds slower every time the interval runs. (At least on my computer.) So it will get 1 second later every 4 days. Or if you want more precise control, you could do something like: Here is an example that is more accurate, and happens at the top of the hour: sub every-hour ( --> Supply:D ) { supply { sub add-next ( $hour --> Nil ) { whenever Promise.at( $hour.Instant ) { emit $hour; add-next( $hour.later(:1hour) ); } } add-next( DateTime.now.truncated-to('hour').later( :1hour ) ); } } react whenever every-hour() { say "it's been an hour"; say "the time is $_" } Honestly it would probably be better to use something native to the system to run it once an hour, in case the program dies. On Tue, Apr 7, 2020 at 6:02 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > Windows 7/10 > > Another piece of the puzzle. > > I want to loop Raku program once an hour. > > Is it better use `sleep 3600` or let the program > die and restart every hour from the Task Scheduler. > By better, I mean less of a CPU footprint. > > `sleep` would allow the user to cancel the program > and not have it come back. > > Many thanks, > -T >