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:
- Go
- Kotlin
- Java
- Schema
//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() {
}
}
module example {
verb hourly(Unit) Unit
+cron "0 * * * *"
}
Every 12 hours, starting at UTC midnight:
- Go
- Kotlin
- Java
- Schema
//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() {
}
}
module example {
verb twiceADay(Unit) Unit
+cron "12h"
}
Every Monday at UTC midnight:
- Go
- Kotlin
- Java
- Schema
//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() {
}
}
module example {
verb mondays(Unit) Unit
+cron "Mon"
}