Cron expressions are used to define time-based schedules for automated tasks. Cron expressions in Salesforce are used to schedule tasks to run on specific time or at specific time intervals
While the basic concept of a Cron expression is consistent across different systems, there are key differences of cron expressions in Salesforce and other common systems like Unix/Linux when it comes to formatting, supported features, and specific use cases.
Key Differences for Cron : In Salesforce Vs Other system
Basic Structure:
Salesforce Cron expressions have six mandatory fields, all are Unit of time:
” Seconds Minutes Hours Day_of_month Month Day_of_week “
Standard Cron Expression (Unix/Linux) has five mandatory fields:
” Minutes Hours Day_of_month Month Day_of_week “
Field Details:
- Salesforce explicitly requires Second fields at beginning whereas other system does not have it.
- Salesforce used ‘?’ special characters for unspecific value in cron which other systems don’t have.
- Salesforce used days of week literals like ‘SUN’, ‘MON’ which other systems don’t use.
How to build Cron expression in salesforce
Cron expression is nothing but string literal where you need to specify all 6 mandatory field which indicates when a automatic scheduled job should run. In order to make cron expression flexible to any time it uses various special characters inside it. let’s understand all these special characters.
| Special Characters | What it does | Example |
|---|---|---|
| * | It indicates all values It means ‘Every’ | 0 30 10 * * * means “10:30 AM every day.” |
| ? | It Indicates no specified value It means ‘Any’ it can only be used in Day_of_month and Day_of_week | 0 0 12 5 1 ? means “12:00 PM on the 5th day of January” (whatever day of the week that is). |
| , | It indicates separates value. It means “and.” | 0 0 12 1 3,4,5 ? means “12.00 PM on 1st day of March,April & May” |
| – | It indicates time range It means “From…To..” | 0 0 10-14 ? * SUN means “from 10 am to 2 pm every sunday” |
| / | It indicates Increments. The number before the slash specifies when the interval begins. The number after the slash is the interval. | 0 0 1/3 * * * means “starting from 1:00 AM every 2 hours every day.” |
| # | It indicates the nth weekday of the month. it can only be used for Day_of_week The value before # sign is the weekday. The value after is the occurrence. | 0 0 12 ? * 5#2 means “12:00 PM on the second Thursday of every month.” Note: Day_of_Week has a value of SUN-SAT or 1-7 |
| L | It indicates the end of a range. It means as “last”. it can only be used in Day_of_month and Day_of_week | 0 0 12 L */1 ? means “12:00 PM on the last day of the month” |
Examples & its explanations
1.Run Every Day at 12:00 PM (Noon)
- Cron Expression:
0 0 12 * * ? - Explanation: The Job will run at 12 PM , every day of the month, every month. The
?in theDay_of_Weekfield indicates that this field is not used.
2. Run Every Sunday at 5:30 PM
- Cron Expression:
0 30 17 ? * 1 - Explanation: The Job will run at 5.30 PM , every month, on Sunday. The
?in theDay_of_Monthfield indicates that this field is not used.
3. Run thrice a day on Weekends for month of January
- Cron Expression:
0 0 0/4 ? JAN 1,7 - Explanation: The Job will run at every 4 hours, in January, on Sunday, Saturday.
4. Run Every 15 Minutes
- Cron Expression:
0 */15 * * * ? - Explanation: This job will run at the 0th second of every 15th minute, regardless of the hour, day, month, or day of the week.
5. Run Every Monday and Wednesday at 9:00 AM
- Cron Expression:
0 0 9 ? * MON,WED - Explanation: This job will run at the 0th second and 0th minute of the 9th hour (9 AM) on every Monday and Wednesday.
6. Run from Mon to Fri, midnight to 6 am in month of December
- Cron Expression:
0 0 0-6 ? 12 MON-FRI - Explanation: The Job will run from 12 AM (midnight) to 6 AM , in December, from Monday to Friday .
Hands-On Cron Building Tool : SfCronMaker
Practice and test your cron here,

this web tool helps you build Cron expressions exclusively for Salesforce with an easy-to-use interface. It allows you to input values for each field and provides a human-readable description of the resulting schedule.




