how to set CRON for a batch class which needs to be scheduled at 10PM daily
Adding an answer because I always end up here and then have to look through the docs to remember the syntax:
second minute hour day_of_month month day_of_week optional_year
second: 0 (this doesn't actually do anything) minute: 0–59 hour: 0-23 day_of_month: 1-31 - * ? / L W month: 1-12 JAN-DEC , - * / day_of_week: 1-7 SUN-SAT , - * ? / L # optional_year: null or 1970–2099 , - * / Character Description , Delimits values. Example: JAN, MAR, APR - Specifies a range. Example: JAN-MAR * Specifies all values ? Specifies no specific value / Specifies increments. Example: Day_of_month = 1/5, the will run every fifth day of the month, starting on the first of the month. L Specifies the end of a range (last). See docs for more details W Specifies the nearest weekday of the given day. Example: 20W. If 20th is a Saturday, the class runs on the 19th # Specifies the nth day of the month, in the format weekday#day_of_month. Example: 2#2 means the class runs on the second Monday of every month.
Expression Description 0 0 13 * * ? Class runs every day at 1 PM. 0 0 22 ? * 6L Class runs the last Friday of every month at 10 PM. 0 0 10 ? * MON-FRI Class runs Monday through Friday at 10 AM. 0 0 20 * * ? 2010 Class runs every day at 8 PM during the year 2010.
String jobID = System.schedule('My Scheduable', '0 0 22 * * ? *' , new MyScheduable());