I have a requirement where i need to run an apex batch job every 4 hours daily monday to friday and all months in a year. I looked at the apex cron job documentation to be setup using code snippets in execute anonymous window. But it is not very clear. I am not sure whether i can do this through the gui but i would like to atleast do this through the system.schedule at run time is fine. Could you guys give me exact syntax for the cron please?
If you use the following chron string for your scheduled job, it will run every 4 hours (at set times) Monday through Friday.
apexScheduledJob j = new apexScheduledJob (); String sch = '0 0 0,4,8,12,16,20 ? * MON-FRI'; System.schedule('My Job', sch, j);
If you wanted it to run every day, you would just change it to
String sch = '0 0 0,4,8,12,16,20 ? * *';
use this site to make cron for every scenario. cronmaker