I have the scheduler class, when I was about to set the Apex scheduler, I noticed that I can only select the time which will be every hour but i need to run it every 5 minutes, can you give me some ideas to achieve this?  This is my scheduler class  global class CaseBreachTAT_Scheduler implements Schedulable{    global void execute(SchedulableContext sc) {       CaseBreachTAT_Batch CaseBT_B = new CaseBreachTAT_Batch();        database.executebatch(CaseBT_B);    } }
14400
Using the salesforce GUI it seams impossible to schedule a job every 15 minutes. Or more than once a day.
109979
I'm New to Jenkins. I have a job which i need to schedule every 1 hour.  I am using   * */1 * * *    but it is not working effectively.  Please provide any other solution.
6182
I have written the following batch apex class and corresponding test class. Tests are successful but the execute method is never called. I have attempted to debug to try to pinpoint the problem but have had no luck.   Batch Class  global class BatchAddToCampaign implements Database.Batchable&lt;sObject&gt;,  Database.Stateful {     global final Id campaignId;     global final Set&lt;Id&gt; qKeys;      global BatchAddToCampaign(Id campaignId, Set&lt;Id&gt; qKeys){         this.campaignId = campaignId;         this.qKeys = qKeys;     System.Debug('this.campaignId is ' + campaignId);              System.Debug('this.qkeys is ' + qKeys);                       }      global Database.QueryLocator start(Database.BatchableContext BC) {         return Database.getQueryLocator('Select Id From Lead Where Id In :qKeys');     }      global void execute(Database.BatchableContext BC, List&lt;Lead&gt; scope) {         System.Debug('Starting Execute Method!');                  Integer collsize;          List&lt;CampaignMember&gt; cm = new List&lt;CampaignMember&gt;();            Map&lt;Id, Campaign&gt; cmMap = new Map&lt;Id, Campaign&gt;([Select (Select LeadId From CampaignMembers) From Campaign c Where Id = :campaignId]);          for(Lead myLeads : scope) {              CampaignMember newCM = new CampaignMember(              CampaignId = campaignId,              LeadId = myLeads.Id,              status = 'Added' );                   if (!cmMap.containsKey(myLeads.Id)) {                      cm.add(newCM);                       collsize = cm.size();                  }          }           try {              Database.insert(cm);           } catch (DmlException ex) {             System.Debug('Insert failed ' + ex);          }             }      global void finish(Database.BatchableContext BC) {         AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed,  TotalJobItems, CreatedBy.Email From AsyncApexJob Where Id = :BC.getJobId()];         // Send an email to the Apex job's submitter notifying of job completion.         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();         String[] toAddresses = new String[] {a.CreatedBy.Email};         mail.setToAddresses(toAddresses);         mail.setSubject('Add to Campaign ' + a.Status);         String campaignURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + campaignId;         mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems + ' batches with '+ a.NumberOfErrors + ' failures. ' + 'Link to Campaign: ' + campaignURL);         Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });     } }   Test Class  @isTest public class BatchAddToCampaignTest {     static testMethod void testMethod1()     {         List&lt;Lead&gt; lstCM= new List&lt;Lead&gt;();         for(Integer i=0 ;i &lt;1;i++){             Lead myLead = new Lead();             myLead.Id = '00Q1U00000KqFcDUAV';             lstCM.add(myLead);             Integer collSize = lstCM.size();              System.debug('List Collection Size is ' + collSize);                 {                  System.debug('Start Set');                 Set&lt;Id&gt; leadIds = (new Map&lt;Id,SObject&gt;(lstCM)).keySet();                 System.debug('End Set');                 Integer collSizeSet = leadIds.size();                  System.debug('Set Collection Size is ' + collSizeSet);                 Id workingCampaignId = '7011U000000RWRAQA4';                  Test.startTest();                  //BatchAddToCampaign ba = new BatchAddToCampaign(workingCampaignId, leadIds);                 DataBase.executeBatch(new BatchAddToCampaign(workingCampaignId, leadIds));                  Test.stopTest();                   }             }      } }
494
i have created a schedulable class which has to trigger a batch job. The run method for the batch class will get list of data to process from a webservice callout. Now, i got the exception below. Any suggestions please.     System.CalloutException: Callout from scheduled Apex not supported.   global class scheduledDeltaBatchable implements Schedulable {    global void execute(SchedulableContext sc) {     ID batchprocessid = BatchUpsertSAPCustomerMasterBPSync.run(SAPServices.GetSAPCustomerMasterBPSync('Delta'));    } }
73722
Is there a full featured, job scheduling package available for PHP? I'm looking for the PHP equivalent to Java's . I'm fine having things triggered externally from cron to drive the system. The functionality I'd be looking for:   Ability to register task (class/method) to be called at given intervals. Ability to specify whether a given task can be run multiple times (potentially long running methods should not be run multiple times in certain cases). All registered entries/methods could be run in parallel (jobs are backgrounded so that they do not block other timed tasks). Ability to set a timeout for a given task. Ability to update job control dynamically, so for instance you could disable some tasks or change their frequency without code changes.   I know it is a lot to ask, but it seems like a useful batch of features and I thought someone might have put together some portion of them.  If this or some portion of this does not already exist, any pointers to putting one together or an open source project that has a reasonably featureful implementation of some subset of these?
58054
pse__Timecard_Header__c th1 = new pse__Timecard_Header__c(                 CurrencyIsoCode         = 'USD',                 pse__Project__c         = project.ID,                 pse__Resource__c        = pmResource.Id,                 pse__Monday_Hours__c    = 8,                 pse__Tuesday_Hours__c   = 8,                 pse__Wednesday_Hours__c = 8,                 pse__Thursday_Hours__c  = 8,                 pse__Friday_Hours__c    = 8,                 pse__Start_Date__c      = Date.today().toStartOfWeek(),                 pse__End_Date__c        = Date.today().toStartOfWeek()+6             );              insert th1;            System.runAs(pmUser)              {                  delete th1;                  system.assert([select ID from pse__Timecard_Header__c WHERE Id = :th1.Id ].IsEmpty());            }             system.assertEquals(th1.Period__c, c2g__codaPeriod__c.Id);
65661
I have a few PCs that are losing time and I'd like Windows to sync them more often with the Internet time.  I think the Windows default attempts to update only once per day, and does not update if the time server is not available (which seems to happen quite often) meaning the PCs can end up 20 or 30 seconds out.  I'd like to create a scheduled task to do this say every 5 minutes and if the default time server is not available use mul
117512
I am trying to run a SQL code (I use MySQL). What I want to do is to set DATE_REACT a value when the first condition is satisfied, and a different value when the first condition is not satisfied. The problem is that the first condition is executed always, even when it shouldn't. What I am doing wrong?  UPDATE BILLS SET STATE = 2, DATE_REACT = CASE  WHEN (DATE_EM &lt;= CURTIME() &lt;= ADDTIME(DATE_EM, '00:02:00')) THEN ADDTIME(CURTIME(), '00:13:00') ELSE ADDTIME(DATE_REACT, '00:13:00') END WHERE STATE = 1;
69590
I've recently run across multiple needs to execute multiple different batch jobs at the same time, and almost immediately hit the (somewhat inexplicable) SFDC limit of 5 batch jobs queued at once.  I've worked around this limit in a number of ways, none of which seem ideal to me.   returning a Iterable&lt;SObject&gt; from the start method, which contains a mix of all the SObjects I need to act upon, and then use dynamic inspection to figure out what I'm supposed to be doing on each row in the execute method. This seems fine for small jobs, but wouldn't presumably scale to millions of records due to heap size etc. using a scheduled apex job that runs once, executes a batch, and then that batch in its finish method schedules another apex job (to run in say 1 minute) that executes the next batch in the chain, and so on.   Is there a more viable/flexible pattern that I could be using? What I really need is a flexible work queue where on-demand, not-very-time-sensitive batch jobs can be queued for future (serial) execution based on user activity. And that doesn't violate platform limits of batch jobs or scheduled jobs - really needs to contribute a max of 1 scheduled or batch job at any given point.  Not sure it will help, but the characteristics of the job set I'm envisioning are this:   each task executes on a single SObject type and does one job: e.g. setting unset fields, doing fake M-D rollups, etc. some tasks are operating on a small subset of a table, others need to walk over every Contact/Lead/etc. with potentially millions of rows per batch job. while some tasks are known to be needed every N hours / days, most of them are needed only after some user-driven operation: e.g. click a big red button in an admin console, do something to more than N records, or a new/updated record of a certain type requires its downstream records to be operated upon.
56244
I have a method that I would like to call.  However, I'm looking for a clean, simple way to kill it or force it to return if it is taking too long to execute.  I'm using Java.  to illustrate:  logger.info("sequentially executing all batches..."); for (TestExecutor executor : builder.getExecutors()) { logger.info("executing batch..."); executor.execute(); }   I figure the TestExecutor class should implement Callable and continue in that direction.  But all i want to be able to do is stop executor.execute() if it's taking too long.  Suggestions...?  EDIT  Many of the suggestions received assume that the method being executed that takes a long time contains some kind of loop and that a variable could periodically be checked. However, this is not the case.  So something that won't necessarily be clean and that will just stop the execution whereever it is is acceptable.
17504
This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through the resources here and use them to shape more specific questions. To browse all canonical questions and answers, including more unit test resources, navigate to the  tag.  I'm testing asynchronous code - like Batch Apex, Queueable Apex, @future methods, or Scheduled Apex - and I'm getting unexpected results. It seems like portions of my code aren't running, or I'm getting confusing errors about batch invocations. How do I effectively test this kind of code?
102470
I'll be working on creating a apex schedule class and I just need a pointer to start is that possible if you can have a working small sample where I can understand how the mechanics work and I have googled but not find what exactly I want and also I looked at the salesforce site
93759
I have  a  requirement where a future method need to be called from batch apex ,I came across various articles stating that a future method could not be called from the batch. Is there any alternate solutions for that?
13127
I want to schedule a task to run on a regular basis and have heard that Cron is the way to do this.  How do I add Cron jobs in Ubuntu?
19425
global class ScheduleBatch implements Schedulable {      global void execute(SchedulableContext sc) {       BatchArticleUpdateCase batch = new BatchArticleUpdateCase();        database.executebatch(batch);     }     Public static void SchedulerMethod(){      } }
87949
After the upgrade of salesforce to Spring 15, I am getting this error "Error: You have exceeded the maximum number (5) of Apex scheduled jobs." when scheduling more than 5 batches. I have this issue in several environment. I used to more than 20 batches scheduled at once.   On the link below, it says that I can schedule up to 100 batches but I am being restricted to 5 only.   I can't have more than 5 jobs here.
78453
I have been watching how to implement the batch for sending more than 10 email but I get errors. When I send emails I have a limit 5 and also are sent several times to the same user email  global class SendBatchClass implements Database.Batchable&lt;sObject&gt;, Database.AllowsCallouts{     String query = '';      global Batchname(){     }     global SendBatchClass(String newBodyBatch,...){        this.body = newBodyBatch;        try{...}        catch(){...}     }     global Database.QueryLocator start(Database.BatchableContext BC) {          return Database.getQueryLocator(query);     }     global void execute(Database.BatchableContext BC, List&lt;Contact&gt; scope) {         SES sesEmail = new SES(as3.key,as3.secret);         for(sObject s: scope){             sesEmail.sendEmail(subRecipients,sender,subject,newBody);         }     }     global void finish(Database.BatchableContext BC) {      } }