Job.apex

  • Docs
  • Tutorials
Docs Menu
  • Job
  • Job Methods
    • Constructors
    • Common Methods
    • Cron Expression Job Methods
    • Repeating Job Methods
  • Jobs Methods

Cron Expression Job Methods Guide

Cron Expression Job Methods

cron

Specify the cron expression.

new Job('test', R.debug).cron('0 0 0 1 3 ?').getCronExpression()
// 0 0 0 1 3 ?

atSecond

Specify the second component of the cron expression.

new Job('test', R.debug).atSecond(10).getCronExpression()
// 10 0 0 * * ?

atMinute

Specify the minute component of the cron expression.

new Job('test', R.debug).atMinute(30).getCronExpression()
// 0 30 0 * * ?

atHour

Specify the hour component of the cron expression.

new Job('test', R.debug).atHour(12).getCronExpression()
// 0 0 12 * * ?

onDay

Specify on which day of month.

new Job('test', R.debug).onDay(12).getCronExpression()
// 0 0 0 12 * ?

fromDay

Specify from which day, usually used with 'everyDays'.

new Job('test', R.debug).fromDay(2).everyDays(3).getCronExpression()
// 0 0 0 2/3 * ?

onDays

Specify on which days.

new Job('test', R.debug).onDays(new List{ 3, 4, 5 }).getCronExpression()
// 0 0 0 3,4,5 * ?

betweenDays

Specify a day range.

new Job('test', R.debug).betweenDays(2, 5).getCronExpression()
// 0 0 0 2-5 * ?

everyDay

Specify every day.

new Job('test', R.debug).everyDay().getCronExpression()
// 0 0 0 * * ?

everyDays

Specify every N days.

new Job('test', R.debug).betweenDays(1, 20).everyDays(2).getCronExpression()
// 0 0 0 1-20/2 * ?

inMonth

Specify in which month.

new Job('test', R.debug).inMonth('Sep').getCronExpression()
// 0 0 0 * 9 ?

fromMonth

Specify from which month.

new Job('test', R.debug).fromMonth(1).everyMonths(2).getCronExpression()
// 0 0 0 * 1/2 ?

inMonths

Specify in which months.

new Job('test', R.debug).inMonths(new List{ 'March', 'Octo' }).getCronExpression()
// 0 0 0 * 3,10 ?

betweenMonths

Specify the month range.

new Job('test', R.debug).betweenMonths(1, 'July').getCronExpression()
// 0 0 0 * 1-7 ?

everyMonth

Specify every month.

new Job('test', R.debug).everyMonth().getCronExpression()
// 0 0 0 * * ?

everyMonths

Specify every N months.

new Job('test', R.debug).betweenMonths(1, 12).everyMonths(2).getCronExpression()
// 0 0 0 * 1-12/2 ?

onDayOfWeek

Specify on which day of week.

new Job('test', R.debug).onDayOfWeek(1).getCronExpression()
// 0 0 0 ? * 2

fromDayOfWeek

Specify from which day of week.

new Job('test', R.debug).fromDayOfWeek(1).everyDaysOfWeek(2).getCronExpression()
// 0 0 0 ? * 2/2

onDaysOfWeek

Specify on which days of week.

new Job('test', R.debug).onDaysOfWeek(new List{ 1, 'Tu' }).getCronExpression()
// 0 0 0 ? * 2,3

betweenDaysOfWeek

Specify the day of week range.

new Job('test', R.debug).betweenDaysOfWeek(2, 'Sun').getCronExpression()
// 0 0 0 ? * 3-1

everyDayOfWeek

Specify every day of week.

new Job('test', R.debug).everyDayOfWeek().getCronExpression()
// 0 0 0 ? * *

everyDaysOfWeek

Specify every N days of week.

new Job('test', R.debug).betweenDaysOfWeek(1, 5).everyDaysOfWeek(2).getCronExpression()
// 0 0 0 ? * 2-6/2

inYear

Specify in which year.

new Job('test', R.debug).inYear(2018).getCronExpression()
// 0 0 0 * * ? 2018

fromYear

Specify from which year.

new Job('test', R.debug).fromYear(2018).everyYears(2).getCronExpression()
// 0 0 0 * * ? 2018/2

inYears

Specify in which years.

new Job('test', R.debug).inYears(new List{ 2018, 2019 }).getCronExpression()
// 0 0 0 * * ? 2018,2019

betweenYears

Specify year range.

new Job('test', R.debug).betweenYears(2018, 2020).getCronExpression()
// 0 0 0 * * ? 2018-2020

everyYear

Specify every year.

new Job('test', R.debug).everyYear().getCronExpression()
// 0 0 0 * * ? *

everyYears

Specify every N years.

new Job('test', R.debug).betweenYears(2018, 2050).everyYears(2).getCronExpression()
// 0 0 0 * * ? 2018-2050/2

onLastDayOfMonth

Specify on the last day of month.

new Job('test', R.debug).onLastDayOfMonth().getCronExpression()
// 0 0 0 L * ?

onLastWeekdayOfMonth

Specify on the last week day of month.

new Job('test', R.debug).onLastWeekdayOfMonth().getCronExpression()
// 0 0 0 LW * ?

onNearestWeekday

Specify on nearest weekday of this day.

new Job('test', R.debug).onNearestWeekday(20).getCronExpression()
// 0 0 0 20W * ?

onLastDayOfWeek

Specify on the last day of week.

new Job('test', R.debug).onLastDayOfWeek().getCronExpression()
// 0 0 0 ? * L

onLast

Specify on the last 'Monday'.

new Job('test', R.debug).onLast('Mon').getCronExpression()
// 0 0 0 ? * 2L

on1st

Specify on the first 'Monday'.

new Job('test', R.debug).on1st('Mon').getCronExpression()
// 0 0 0 ? * 1#2

on2nd

Specify on the second 'Monday'.

new Job('test', R.debug).on2nd('Mon').getCronExpression()
// 0 0 0 ? * 2#2

on3rd

Specify on the third 'Monday'.

new Job('test', R.debug).on3rd('Mon').getCronExpression()
// 0 0 0 ? * 3#2

on4th

Specify on the fourth 'Monday'.

new Job('test', R.debug).on4th('Mon').getCronExpression()
// 0 0 0 ? * 4#2

on5th

Specify on the fifth 'Monday'.

new Job('test', R.debug).on5th('Mon').getCronExpression()
// 0 0 0 ? * 5#2

Contribute on Github! Edit this section.