Aptitude (12) C (2) C++ (10) CSS (1) Data Structure (2) English (7) General (14) HTML (3) Integration (1) Itinerary and Travel Cost (1) Java (29) JQ (5) JS (5) JSP (1) Lightning (14) logical (3) Math (1) Music Notation (17) MySql (4) Network (1) Regex (1) salesforce (131) Servlet (4) SF Admin (31) SF Dev (102) SQL (4) SQL_SERVER (1) StudyPoints (2) ytChannels (2) अन्ताक्षरी (4)

CronTrigger || CronJobDetail || Cron Expressions

CronTrigger: 

CronTrigger is an standard object which contains schedule information for a scheduled job.
This object is available in API version 17.0 and later.
CronExpression
The cron expression used to initiate the schedule.
CronJobDetailId
The ID of the CronJobDetail record containing more details about this scheduled job.
EndTime
The date and time when the job either finished or will finish.
NextFireTime
The next date and time the job is scheduled to run. null if the job is not scheduled to run again.
OwnerId
Owner of the job.
PreviousFireTime
The most recent date and time the job ran. null if the job has not run before current local time.
StartTime
The date and time when the most recent iteration of the scheduled job started.
State
The current state of the job. The job state is managed by the system. Possible values are:
  • WAITING—The job is waiting for execution.
  • ACQUIRED—The job has been picked up by the system and is about to execute.
  • EXECUTING—The job is executing.
  • COMPLETE—The trigger has fired and is not scheduled to fire again.
  • ERROR—The trigger definition has an error.
  • DELETED—The job has been deleted.
  • PAUSED—A job can have this state during patch and major releases. After the release has finished, the job state is automatically set to WAITING or another state.
  • BLOCKED—Execution of a second instance of the job is attempted while one instance is running. This state lasts until the first job instance is completed.
  • PAUSED_BLOCKED—A job has this state due to a release occurring. When the release has finished and no other instance of the job is running, the job’s status is set to another state.
TimesTriggered
The number of times this job has been triggered.
TimeZoneSidKey
Returns the timezone ID. For example, America/Los_Angeles.

CronJobDetail:

Contains details about the associated scheduled job, such as the job’s name and type. This object is available in API version 29.0 and later.
FieldDetails
JobType
The type of the associated scheduled job. The following are the available job types. Each job type label is listed with its value in parenthesis. Use the job type value when querying for a specific job type.
  1. Data Export (0)
  2. Dashboard Refresh (3)
  3. Reporting Snapshot (4)
  4. Scheduled Apex (7)
  5. Report Run (8)
  6. Batch Job (9)
Name
The name of the associated scheduled job.
Cron Expressions:
A cron expression is a string consisting of six or seven subexpressions (fields) that describe individual details of the schedule.
These fields, separated by white space, can contain any of the allowed values with various combinations of the allowed characters for that field.

Table : Cron Expressions Allowed Fields and Values
NameRequiredAllowed ValuesAllowed Special Characters
SecondsY0-59, - * /
MinutesY0-59, - * /
HoursY0-23, - * /
Day of monthY1-31, - * ? / L W C
MonthY0-11 or JAN-DEC, - * /
Day of weekY1-7 or SUN-SAT, - * ? / L C #
YearNempty or 1970-2099, - * /

Example :Cron Expressions
Cron expressions can be as simple as * * * * ? * or as complex as 0 0/5 14,18,3-39,52 ? JAN,MAR,SEP MON-FRI 2002-2010.
Here are some more examples:
ExpressionMeans
0 0 12 * * ?Fire at 12:00 PM (noon) every day
0 15 10 ? * *Fire at 10:15 AM every day
0 15 10 * * ?Fire at 10:15 AM every day
0 15 10 * * ? *Fire at 10:15 AM every day
0 15 10 * * ? 2005Fire at 10:15 AM every day during the year 2005
0 * 14 * * ?Fire every minute starting at 2:00 PM and ending at 2:59 PM, every day
0 0/5 14 * * ?Fire every 5 minutes starting at 2:00 PM and ending at 2:55 PM, every day
0 0/5 14,18 * * ?Fire every 5 minutes starting at 2:00 PM and ending at 2:55 PM, AND fire every 5 minutes starting at 6:00 PM and ending at 6:55 PM, every day
0 0-5 14 * * ?Fire every minute starting at 2:00 PM and ending at 2:05 PM, every day
0 10,44 14 ? 3 WEDFire at 2:10 PM and at 2:44 PM every Wednesday in the month of March
0 15 10 ? * MON-FRIFire at 10:15 AM every Monday, Tuesday, Wednesday, Thursday and Friday
0 15 10 15 * ?Fire at 10:15 AM on the 15th day of every month
0 15 10 L * ?Fire at 10:15 AM on the last day of every month
0 15 10 ? * 6LFire at 10:15 AM on the last Friday of every month
0 15 10 ? * 6LFire at 10:15 AM on the last Friday of every month
0 15 10 ? * 6L 2002-2005Fire at 10:15 AM on every last friday of every month during the years 2002, 2003, 2004, and 2005
0 15 10 ? * 6#3Fire at 10:15 AM on the third Friday of every month
0 0 12 1/5 * ?Fire at 12 PM (noon) every 5 days every month, starting on the first day of the month
0 11 11 11 11 ?Fire every November 11 at 11:11 AM


No comments: