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
Ranjith DevRanjith Dev 

Apex cpu time limit exceeded for schedule job


In my Client org iam facing an issue is 'Apex cpu time limit exceeded' for Schedule job. Can you please help me on this.

Thank you
SwethaSwetha (Salesforce Developers) 
HI Ranjith,
1. This error generally occurs if transactions consume too much CPU time. Salesforce has a timeout limit for transactions based on CPU usage. If transactions consume too much CPU time, Salesforce shut them down as a long-running transaction.

2. To fix the issue, you need to optimize the code involved following the best practices described in the below articles.


3. Please use the following limit methods in your code to debug the amount of CPU time currently used in the transaction:

Returns the CPU time (in milliseconds) accumulated on the Salesforce servers in the current transaction.

Returns the time limit (in milliseconds) of CPU usage in the current transaction.


Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you