You need to sign in to do that
Don't have an account?
Anil Kamisetty
Build the Cron Expression to run a Job every 30 Minutes
My requirement is to schedule a Job every 30 minutes. I can do this using two CRON Expresssions (as given below), but I want to see if we can do this in one expression ? Advantage of having one single job is that "if the job take more than 30 minutes to process, second job wont fire". By having two different expressions, they can be running together.
String cronStr1 = '0 00 * * * ?';
String cronStr2 = '0 30 * * * ?';
String cronStr1 = '0 00 * * * ?';
String cronStr2 = '0 30 * * * ?';
String cro ='0 0/30 * * * ?';
System.StringException: Seconds and minutes must be specified as integers: 0 0/30 * * * ?
String cronStr = '0 0,30 * * * *';
OR
String cronStr = '0 30 * * * ?';
Reference Links:
https://webkul.com/blog/cron-expression-for-scheduling-jobs-in-salesforce/
http://www.cloudforce4u.com/2013/09/batch-apex-scheduling-in-apex-batch.html
http://sfdcsrini.blogspot.com/2014/06/how-to-execute-batch-apex-class-for.html
Note: If the above things are not works then we must have to go with the two CRON because i think schedule your batch for every 30 min '0 30 * * * ?'. then It means it will run every hours 30th minutes not for 30mins interval.
Can you please Let me know if it works or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj
System.StringException: Seconds and minutes must be specified as integers
And String cronStr = '0 30 * * * ?';runs the job ever hour by at 30 minute time (i.e. 1:30, 2:30, 3:30, 4:30 etc). Creating two separate expressions seems to be the way, but want to see if anyone has found any other way.
RecurringScheduleJob: https://developer.salesforce.com/forums/?id=906F00000008yFvIAIDoesn't exist anymore since 2013 perhaps.
http://mukeshkumararchitecture.blogspot.fr/2017/05/salesforce-scheduling-schedule-job.html
Recent post (2017) but wrong example because
RecurringScheduleJobhas been deprecated (nothing in Apex documentation).Minutes: Values: 0–59 Special Characters: None (I missed that part and that was possible in the past, many examples with 0/30 or 0,30)
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
The simple workaround is two schedules now as you have done.
String cronStr1 = '0 00 * * * ?';
String cronStr2 = '0 30 * * * ?';
Did you mean to run the same job twice with these 2 cron expression? If we schedule the Job with one say (String cronStr1 = '0 00 * * * ?';) and trying to schedule with 2nd its saying job is already scheduled for execution. How did you scheduled it twice..can u pls mention here..it will help
I think you might have used same job name for both the schedules. Please use different job names for each schedule. Hope it will solve the issue.
Thanks.
Abhishek
I know this is a very old post, But recently I came across a simple tool that helps in generating the code for scheduling automatically based on the frequency you select. Please take a look.
http://radix2.tech/tools/sfdc-batch/
Thanks
Selva
Cron Expression to run a Job every 30 Minutes is given below
cron expression = */30 * * * *
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi