The execution logic of the batch class is called once for each batch of records. The default batch size is 200 records. You can also specify
a custom batch size. Furthermore, each batch execution is considered a discrete transaction. With each new batch of records, a new set
of governor limits is in effect. In this way, it’s easier to ensure that your code stays within the governor execution limits. Another benefit
of discrete batch transactions is to allow for partial processing of a batch of records in case one batch fails to process successfully, all
other batch transactions aren’t affected and aren’t rolled back if they were processed successfully.
There are three main steps involved in this
Batch apex gives us the advantage to run jobs that might require a lot more that the usual governor limit contexts, example Batch job are made to perform common UPSERT operation on a scheduled basis. The Batch apex, can be used to conveniently perform time to time task and some real complex job ranging from data cleansing, archiving the data to the other quality improvements
Learn more about Batch Apex here.
Step 2: Write the Schedulable class
Now, We have the batch class ready and it has to be in a schedulable context in-order to schedule the batch. You can learn more about schedulable apex here
Example of a Scheduled Apex
Step 3: Schedule the class by executing anonymous
Finally now we can schedule the batch class, there are two ways by which we can schedule the batch class
Code to be executed
If you want to run it as frequent as 15,30 or N mins .....