Skip to main content Link Search Menu Expand Document (external link)


A simplified cron trigger with human-readable syntax.

:secondExecute rule every second:second
:minuteExecute rule every minute:minute
:hourExecute rule every hour:hour
:dayExecute rule every day:day
:weekExecute rule every week (on Monday):week
:monthExecute rule every month:month
:yearExecute rule once a year:year
:mondayExecute rule every Monday at midnight:monday
:tuesdayExecute rule every Tuesday at midnight:tuesday
:wednesdayExecute rule every Wednesday at midnight:wednesday
:thursdayExecute rule every Thursday at midnight:thursday
:fridayExecute rule every Friday at midnight:friday
:saturdayExecute rule every Saturday at midnight:saturday
:sundayExecute rule every Sunday at midnight:sunday
[Numeric].secondsExecute rule every X seconds5.seconds
[Numeric].minutesExecute rule every X minutes3.minutes, 1.5.minutes
[Numeric].hoursExecute rule every X hours10.hours
MonthDayExecute rule at midnight on the given MonthDay. The value can either be a MonthDay object or a StringMonthDay.of(3,14), '03-14'
:atLimit the execution to specific times of day. The value can either be a String or a TimeOfDay objectat: ‘16:45’ or at: 16, m: 45)

Note: The [Numeric].seconds specifies a Duration / interval. A floating point can also be used to specify a fractional unit of time, e.g. 1.5.hours


rule 'Log the rule name every minute' do |rule|
  description 'This rule will create a log every minute'
  every :minute
  run { "Rule '#{}' executed" }
rule 'Log an entry at 11:21' do |rule|
  every :day, at: '11:21'
  run {"Rule #{} run at #{}") }

# The above rule could also be expressed using TimeOfDay class as below

rule 'Log an entry at 11:21' do |rule|
  every :day, at: 11, m: 21)
  run {"Rule #{} run at #{}") }
rule 'Log an entry Wednesdays at 11:21' do |rule|
  every :wednesday, at: '11:21'
  run {"Rule #{} run at #{}") }
rule 'Every 5 seconds' do |rule|
  every 5.seconds
  run { "Rule #{} executed" }
rule 'Every 14th of Feb at 2pm' do 
  every '02-14', at: '2pm'
  run { "Happy Valentine's Day!" }