Liking cljdoc? Tell your friends :D

Saturn

Saturn is a library for building and managing periodic cron-like jobs.

Usage

(require '[mount.core :as mount]
         '[saturn.core :as saturn]
         '[saturn.store.pg :as store])


(def commands
  {"cmd1" {:func #(println "cmd1")
           :schedule [:every :monday :at 9 0]}})


(defn report-error [{:keys [command error]}]
  (println "cron error" command error))


(defn report-overlap [{:keys [command]}]
  (println "cron command overlap" command))

         
(mount/defstate cron
  :start (saturn/make commands
           {:store            (store/pg db-conn)
            :restart-skipped? true
            :cleanup-history? true
            :report-error     report-error
            :report-overlap   report-overlap})
  :stop  (saturn/stop cron))

Options

optiontypedescription
storesaturn.store/Stateschedule state storage
restart-skipped?booleanrestart previously unfinished jobs
cleanup-history?booleanremove runs history from storage
report-errorIFnfunction to report run errors
report-overlapIFnfunction to report overlap errors

Schedule syntax

Question mark means component is optional, star - it repeats 0 or more times.

[:every period? unit <:at hour? minute>*]

componentdescription
periodint, like in "every 3 days" or "every 30 minutes"
unitminute(s), hour(s), day(s) and week day names
hourfrom 0 to 24
minutefrom 0 to 60

Examples:

  • [:every :minute]
  • [:every 2 :hours :at 50]
  • [:every 1 :day :at 8 0, 13 0, 20 0]
  • [:every :monday :at 9 0]

Can you improve this documentation? These fine people already did:
Alexander Solovyov & Igor Bondarenko
Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close