You can create a custom object to store error information whenever the job throws an error and set up a workflow rule on this object to send email alerts if there is an error.
For example:
Error Log custom object with just one custom field, Trace__c, although you could break it out into different, more specific fields if you like.
So in apex class that you schedule, create a new Error Log object in catch statements to record specific error information when the job fails.
try{
//Some DML statement
} catch (Exception e) {
Error_Log__c log = new Error_Log__c();
log.trace__c = 'Type: ' + e.getTypeName() + '\n' + 'Cause: ' + e.getCause() + '\n' + 'Message: '
+ e.getMessage() + '\n' + 'Line #: ' + e.getLineNumber() + '\n' + e.getStackTraceString() + '\n'
+ 'Some Custom Variable Information From Class: ' + myClassVariable;
insert log;
}
Then you can set up a workflow on the error log object to send email whenever a new error log is created. You can add different information based on what class you are using it in, its fairly flexible.
The one drawback would be that you are using a custom object for this and storing the error data, so you might want to monitor this object and periodically delete old error logs. You can have a batch class that runs monthly and deletes anything over 30 days old.
The advantage to this method is, you only get alerted when there are issues. If you have a lot of scheduled classes, you can also send an email on the job completion. However, with so many classes, some running every night, you don't really need to get an email just to tell you it worked fine. This will only email, when something goes wrong.
000387981

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.