Cron
A cron job is an Empty verb that will be called on a schedule. The syntax is described here.
You can also use a shorthand syntax for the cron job, supporting seconds (s
), minutes (m
), hours (h
), and specific days of the week (e.g. Mon
).
Examples
The following function will be called hourly:
//ftl:cron 0 * * * *
func Hourly(ctx context.Context) error {
// ...
}
import xyz.block.ftl.Cron
@Cron("0 * * * *")
fun hourly() {
}
import xyz.block.ftl.Cron;
class MyCron {
@Cron("0 * * * *")
void hourly() {
}
}
Every 12 hours, starting at UTC midnight:
//ftl:cron 12h
func TwiceADay(ctx context.Context) error {
// ...
}
import xyz.block.ftl.Cron
@Cron("12h")
fun twiceADay() {
}
import xyz.block.ftl.Cron;
class MyCron {
@Cron("12h")
void twiceADay() {
}
}
Every Monday at UTC midnight:
//ftl:cron Mon
func Mondays(ctx context.Context) error {
// ...
}
import xyz.block.ftl.Cron
@Cron("Mon")
fun mondays() {
}
import xyz.block.ftl.Cron;
class MyCron {
@Cron("Mon")
void mondays() {
}
}