I would like to add a schedule to my Schedulable class during the deployment of my code via Salesforce Migration Tool.

For example, one might schedule a class as per this example:

scheduledMerge m = new scheduledMerge();
String sch = '20 30 8 10 2 ?';
String jobID = system.schedule('Merge Job', sch, m);

Is there a way to script the schedule creation during deployment with the Salesforce Migration Tool? If not with the Migration Tool itself, is there any other way of automating this?


3 Answers 3


You could have another job on a schedule whose job it is to schedule this job in question if it isn't already scheduled. I can't think of another way since you can't exercise apex on a deploy.


Decided to use the Force.com CLI and ANT execute to run the APEX code to schedule the class.


The only way to of automating the deployement is right now is CI, you go "Continuous Integration How-To"

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
    – crmprogdev
    Mar 23, 2015 at 20:17
  • thanks for editing Samuel, I'll take care of this in future Mar 24, 2015 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .