Oban.Plugins.Cron (Oban v2.4.0) View Source
Periodically enqueue jobs through CRON based scheduling.
Using the Plugin
Schedule various jobs using {expr, worker}
and {expr, worker, opts}
syntaxes:
config :my_app, Oban,
plugins: [
{Oban.Plugins.Cron,
crontab: [
{"* * * * *", MyApp.MinuteWorker},
{"0 * * * *", MyApp.HourlyWorker, args: %{custom: "arg"}},
{"0 0 * * *", MyApp.DailyWorker, max_attempts: 1},
{"0 12 * * MON", MyApp.MondayWorker, queue: :scheduled, tags: ["mondays"]},
{"@daily", MyApp.AnotherDailyWorker}
]}
]
Options
:crontab
— a list of cron expressions that enqueue jobs on a periodic basis. See Periodic Jobs in the Oban module docs for syntax and details.:timezone
— which timezone to use when scheduling cron jobs. To use a timezone other than the default of "Etc/UTC" you must have a timezone database like tzdata installed and configured.
Instrumenting with Telemetry
The Oban.Plugins.Cron
plugin adds the following metadata to the [:oban, :plugin, :stop]
event:
- :jobs - a list of jobs that were inserted into the database
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Link to this section Types
Specs
Specs
cron_opt() :: {:args, Oban.Job.args()} | {:max_attempts, pos_integer()} | {:paused, boolean()} | {:priority, 0..3} | {:queue, atom() | binary()} | {:tags, Oban.Job.tags()}
Specs
option() :: {:conf, Oban.Config.t()} | {:name, GenServer.name()} | {:crontab, [cron_input()]} | {:timezone, Calendar.time_zone()}
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
start_link([option()]) :: GenServer.on_start()