How to Monitor Your Batch Job

A Batch Job is a program or series of programs that are processed in batch mode and intended to be executed by the Windows Command Interpreter. In many instances, a Batch Job is executed at times when a computer is idle or not in used because of its heavy demands on the computer.

Even though a Batch Job is set up so they can run to completion without manual intervention, it still requires an extra step so you can tell if the program has ran successfully or not. Aside from visiting the history logs of your computer, below are other ways to monitor your Batch program.

The Batch’s ERRORLEVEL or most commonly known as return codes is one of the ways to capture the error in your program. In general rule, an ERRORLEVEL “0” means the command has been executed successfully, and an ERRORLEVEL “1” or “higher” usually tells that there is something wrong in your script.

To display the error on your screen, you should use the  “@Echo On” at the start of the .bat file and before this code:

ECHO "There's an error in your script"

For occasions that you can not attend to your screen while the program is running, you can also direct the results/error in a log file using this command:

IF %ERRORLEVEL% NEQ 0 ECHO %errorlevel% > error.log

However, the suggestions above can consume your valuable time and energy specially if you’re running lots of programs. So to free up your hands and give you more time to do other important tasks, you can use PushMon to automatically alert you each time your program has stop running or did not run at your specified time. PushMon is a Software as a Service (SaaS) tool where you only need to generate a URL to call, set the alert method of your choice such as email or SMS text, etc and specify the time that your batch should be running.

Here’s a screenshot of a PushMon Dashboard. After you set up, add the following commands to your program.
Figure 1. PushMon Dashboard
Figure 1. PushMon Dashboard

@echo on
start "yourprogram"
call :alerts
wget -q -O - %URL_STRING%