System.AsyncException: The Apex job named is already scheduled for execution.

System.AsyncException: The Apex job named is already scheduled for execution.

Hi All,
When i was trying to schedule my class for every 15 miuntes to run. I was getting below error.
System.AsyncException: The Apex job named "Global App Logs Purge" is already scheduled for execution.

e.g.
Schedular_GlobalAppLogPurgeBatch globalPurgeBatchSchedular = new Schedular_GlobalAppLogPurgeBatch();
System.schedule('Global App Logs Purge', '0 0 * * * ? *', globalPurgeBatchSchedular);
System.schedule('Global App Logs Purge', '0 15 * * * ? *', globalPurgeBatchSchedular);
System.schedule('Global App Logs Purge', '0 30 * * * ? *', globalPurgeBatchSchedular);
System.schedule('Global App Logs Purge', '0 45 * * * ? *', globalPurgeBatchSchedular);

When i change the all the 4 job name from "Global App Logs Purge" to "Global App Logs Purge1","Global App Logs Purge2","Global App Logs Purge3","Global App Logs Purge4". I did not get any error. So the conclusion is every Job should be unique.

Corrected Code:
Schedular_GlobalAppLogPurgeBatch globalPurgeBatchSchedular = new Schedular_GlobalAppLogPurgeBatch();
System.schedule('Global App Logs Purge1', '0 0 * * * ? *', globalPurgeBatchSchedular);
System.schedule('Global App Logs Purge2', '0 15 * * * ? *', globalPurgeBatchSchedular);
System.schedule('Global App Logs Purge3', '0 30 * * * ? *', globalPurgeBatchSchedular);
System.schedule('Global App Logs Purge4', '0 45 * * * ? *', globalPurgeBatchSchedular);

I hope this will help you.

Comments

Popular posts from this blog

Custom Setting Creation in Apex Test Class

Error : "Trigger must be associated with a job detail"

AJAX Toolkit Debug Shell

Salesforce Trace Log Query Using Apex

how to get object name from id / prefix value in salesforce

How to Query All the batch classes in your Salesforce Instance using APEX

Creating Salesforce Developer Account

Creating MAP from SOQL Query

Custom Pagination Without Controller (Apex)