Southsoftware.com
   

Error handling in scheduled tasks

A scheduled task can be run automatically many times after it has been created, configured and tested. But what if something goes wrong, for example, the task depends on a file that has been renamed or moved, Internet connection interrupts when the task is being executed? The administrator may want to know about the problem. That is why Advanced Task Scheduler introduces error handling features, which allow taking actions when something wrong happens.

Logging and log files

During execution, Advanced Task Scheduler records task execution messages in a log file or sends them to an email address. Logging options can be configured in the Options section on the user's tab of the Preferences window.

To enable logging and specify log file name: check the "Write Log File" option, in the text box next to this option enter file name of the file where you wish to record log entries. You can check the "Split Log File" option and specify maximum size for a single log file. When size of your log file reaches maximum, Advanced Task Scheduler will create new log file by adding or increasing index number in its file name.

To enable sending logs to email address: check the "Send Logs to EMail" option and specify email address and SMTP options. In Advanced Task Scheduler Professional and Network editions you can send every log message as a separate email or send a bunch of log messages in a single email once a day, week or month.

To log failed tasks only: check the "Log failed tasks only" option. This option is good for error handling. Advanced Task Scheduler will record or email log entries for failed tasks only.

Logging and log files
Click the picture to enlarge.

Conditions

In addition to error logging Advanced Task Scheduler Professional and Network editions provide more powerful error handling feature - conditions. Conditions allow executing one sequence of commands or another depending on the condition. Advanced Task Scheduler allows conditions based on error code or exit code of the program started. Error code is a code that Operating System reports when it starts the program. For example, if the program's executable file does not exist, you'll receive either 2 (File not found) or 3 (Path not found) error code. Error code "0" means that the program has been started successfully. Every program on Windows returns its exit code (integer value) when it finishes to execute. In general, exit code is the result of the operation that the program has performed.

Thus, you can check last error code or last exit code of the program you started and perform different operations in case of success or failure. The example below demonstrates a task that displays message box when program fails to start. In real life, you can send an email message or use any other commands to notify yourself about the error or perform other error handling operations.

LastErrorCode conditions in Advanced Task Scheduler Professional
Click the picture to enlarge.

The example below, demonstrates how to check last exit code. The task will display a message asking user to click either "Yes" or "No" button. And will respond user by displaying different messages depending on what button has been clicked.

LastExitCode conditions in Advanced Task Scheduler Professional
Click the picture to enlarge.

Advanced error handling

If you are familiar with programming or scripting techniques, you can write scripts or bat files for handling more complex conditions and operations.

Categories: Task scheduler

Leave a Reply

   
About us   Cookie policy   Privacy policy   Terms of use   Link to us