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
Sahil YadavSahil Yadav 

Hello mates I am Stuck in Batch class the purpose of batch class to delete the records in org but its getting failed could any one help on this. This batch class is getting executed but not deleting any records from org

Batch Class

public class personBatch implements Database.Batchable<sObject>{
    public Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([SELECT Id, CreatedDate, Name, Phone_No__c FROM Person__c Where CreatedDate = Today]);
    public void execute(Database.BatchableContext bc, List<sObject> scope){
        for (sObject sc : Scope){
            delete sc;
    public void finish(Database.BatchableContext bc){
        System.debug('Finish method is get executed');


Schedulable Class

public class personSchedule implements Schedulable {
    public void execute(SchedulableContext sc){
        personBatch pB = new personBatch();
        Database.executeBatch(pB,200 );


Log Code

personSchedule pS = new personSchedule();
String cronExp = '00 00 5 * * ?';
String jobPerson= System.schedule('personScheduleJobs',cronExp,pS);

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Sahil,

I dont see any issue with the batch. I used the same code to check on Account object and ran the batch anonymously this deleted the Accounts which were created. Can you check if this batch is Scheduled correctly and if this is running ant particular instance.

Sahil YadavSahil Yadav
ya its scheduled properly and showing the status as completed but total batches is 2 and failure also showing 2
Sai PraveenSai Praveen (Salesforce Developers) 
Can you run the batches adhocly and see if this is causing any issues in the debug logs.
Sahil YadavSahil Yadav
I am not getting clearly praveen what you are trying to say how could i able to run adhocly could you please how could i proceed with that.