modal.Cron

class Cron(modal.schedule.Schedule)

Cron jobs are a type of schedule, specified using the Unix cron tab syntax.

Usage

import modal
stub = modal.Stub()


@stub.function(schedule=modal.Cron("* * * * *"))
def f():
    print("This function will run every minute")

We can specify different schedules with cron strings, for example:

modal.Cron("5 4 * * *")  # run at 4:05am every night
modal.Cron("0 9 * * 4")  # runs every Thursday 9am
def __init__(self, cron_string: str) -> None:

Construct a schedule that runs according to a cron expression string.