Skip to content

Instantly share code, notes, and snippets.

@FCO
Created August 11, 2023 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FCO/d2d2383cc1f2f70756e25d9ceb944fe1 to your computer and use it in GitHub Desktop.
Save FCO/d2d2383cc1f2f70756e25d9ceb944fe1 to your computer and use it in GitHub Desktop.
use App::RakuCron::Configuration;
sub print-example(Str $msg, +@params, :$time, :$delta-secs, :$something-else) {
say "$msg (@params[]) ({ $something-else // "" }): ", $time, " -> { $delta-secs // "None" }"
}
config {
# every Mon/Web/Fri at 10:00:00
.run-at: :10hours, :wday<Mon Wed Fri>, { shell "ls -la" }
# every work day at every hour
.run-at: :wday(2..6), :hours(*), { say "running!" }
# every even day at 00:00 and 00:30
.run-at: :day(* %% 2), :0hours, :minutes[0, 30], { say "running!" }
# half in half hour in January
.run-at: :month<Jan>, :minutes[0, 30], { say "running!" }
# run every minute
.run-at: :sec(* %% 5), :capture(\("every 5 secs", :something-else(42))), &print-example;
# Every other second
.run-at: :2delta-secs, :capture("every other second", "bla", "ble"), &print-example;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment