function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DML2020DML2020 

Error scheduling chron job

Via anonymous apex, I'm trying to schedule a job to run at 11pm on the first of every month using the following:

RenewalBatch job = new RenewalBatch();

// Scheduling string parameters
// Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
String 1stOfMonthAt11pm = '0 0 23 1 * *';

System.schedule('Renewal Batch Job Monthly at 11pm', 1stOfMonthAt11pm, job);
 

However, I receive the following error:

Execute Anonymous Error
Line: 5, Column: 8
Unexpected token '1'.

and am unable to resolve this. What could be the issue here?

Best Answer chosen by DML2020
Suraj Tripathi 47Suraj Tripathi 47

Hi DML2020,
enewalBatch job = new RenewalBatch();
// Scheduling string parameters
// Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
String 1stOfMonthAt11pm = '0 0 23 1  * ? * ';   // please use this regex
System.schedule('Renewal Batch Job Monthly at 11pm', 1stOfMonthAt11pm, job);

I hope you find the above solution helpful.
 If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Suraj