I want to write in apex code below of the following to use in System.schedule Method. For Daily i can use this
String sch = '0 0 00 ? * MON-FRI';
How would I schedule a job with the following criteria?
- Every 15 days
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
The system.schedule argument to represent the Date and time of the job is a bit quirky at first, but once you get the hang of it, its really quite simple
To answer you immediate question
Weekly (Here it is set up to run every Saturday at 8am, but you can adjust which day of the week by changing the 6th element, which happens to be a 6 for Saturday)
String sch = '0 0 8 * * 6'
Every 15 Days (Here I have the job running on the 1st and 15th of each month)
String sch = '0 0 00 1,15 * ?'
Monthly (This runs at 8 am on the last day of the month)
string sch = '0 0 8 L * ?'
Take a look at the docs here
Have a similar question I answered here for a different time period, but same general concept