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?
- Weekly
- Every 15 days
- Monthly
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?
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
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm
Have a similar question I answered here for a different time period, but same general concept
Apex cron job command to schedule an apex job to run every 4 hours daily