Knowledge Center > Tutorials
How to Monitor a Scheduled Task in Windows Task Scheduler
|
Using ipMonitor's External Process Monitor and two ipMonitor utilities (sem_check.exe and sem_stamp.exe), it is possible to ensure that a task scheduled using the Windows Task Scheduler has run.
|
The process works as follows:
- The Windows Task Scheduler is set to run a specific task via a batch file. When the task completes successfully, an ipMonitor utility is used to create a file containing a timestamp. This timestamp marks the time when the task must run next.
- ipMonitor uses the External Process Monitor to run a separate ipMonitor utility (sem_check.exe) that checks the file to ensure its timestamp is acceptable, confirming that the Task Scheduler has successfully run. If the timestamp is too old, ipMonitor will view this test as a failure, and Alerts will be sent.
Using this method, you can verify that tasks are running correctly using only drive shares and read permissions on the remote machines.
About Windows Task Scheduler
Microsoft's Task Scheduler comes preinstalled with your Windows system. You can find it in the Control Panel.
Using the Task Scheduler, you can schedule a variety of tasks and system tools. Nearly any application or script (batch file) can be scheduled to run daily, weekly, monthly or at certain times (i.e. on system boot, user logon or system idle). The Task Scheduler automatically launches when you start Windows, and runs in the background.
To learn more about the Windows Task Scheduler, refer to the following links:
http://support.microsoft.com/default.aspx?scid=kb;en-us;308569&sd=tech
http://www.microsoft.com/technet/prodtechnol/windows2000serv/evaluate/featfunc/taskschd.mspx
Before You Begin
Before configuring the External Process Monitor or creating the desired task, proceed with the following:
- Create a new folder named logs on the remote server. This folder can be located on any drive you choose.
- Set security permissions for the new folder. Grant read access to the user account ipMonitor will be running under.
Available Resources
|
Click the ZIP icon to download resources designed to be used with this tutorial. The ZIP file includes two small executable utilities (sem_check.exe and sem_stamp.exe) and text instructions for configuring the task's timing parameters to work with those utilities.
|
|
Click the XML icon to download a preconfigured Monitor to be used with this tutorial.
|
|
Click the PDF icon to open a printable PDF version of this tutorial. It includes all the information found here, including images from the ipMonitor software, diagrams, and links to additional resources.
|
Sample Monitor Settings
| Monitor Name |
Exec:: Task file |
| Monitor Type |
External Process Monitor |
| Returns |
Timing state (expired or valid) of the file generated by the scheduled task. |
| Monitoring Condition |
Expected Return Value: 0 Monitor failure indicates that the file is older than 24 hours. |
Note: Imported Monitors are initially disabled. This allows you to make changes to the default settings before the Monitor is enabled to go live in a production environment. Once the Monitor is imported, the following settings will need to be verified (and if necessary, modified) for the Monitor:
- Executable Name
- Directory
- Command Line Parameters
- Startup Directory
- Credential for Monitoring
To learn more about modifying the above parameters, please refer to the ipMonitor Host System Setup section of this tutorial.
Remote System Setup
In order to monitor a configured task on a remote system, proceed with the following setup instructions:
- Extract the sem_stamp.exe file from the sem_stamp.zip archive into C:\%SystemDirectory%
- Create the desired task using Windows Task Scheduler.
- On the server where the task will occur, create a batch file that will run the desired program as well as sem_stamp.exe.
Note: The sem_stamp.exe executable will create a small file containing a time stamp. This is the file that will be monitored using the External Process Monitor.
Example
The following example illustrates a batch file created to launch the scheduled task "robocopy". The sem_stamp.exe executable will then create a file named taskfile.txt under the \logs folder previously created.
------------------------------------------------------
@Echo off
NET USE \\remoteserver\IPC$ /USER:userid password
ROBOCOPY \\remoteserver\sourcepath \\localserver\destpath
NET USE \\remoteserver\IPC$ /DEL
sem_stamp.exe c:\logs\taskfile.txt
------------------------------------------------------
ipMonitor Host System Setup
Proceed with the following setup on the ipMonitor host machine after you've set up the desired task using Windows Task Scheduler on the remote system, as well as the batch file:
- Extract sem_check.exe from the sem_stamp.zip archive to C:\%SystemDirectory%
- Launch the ipMonitor Administration web interface and create a new External Process Monitor.
Note: For the purposes of this tutorial, we'll be referring to the preconfigured Monitor included in the XML resource download. Alternatively, you can create a new Monitor by clicking the Monitors menu option and then selecting Add a Monitor. Choose the External Process Monitor from the Windows Based category.
Identification

- Enter a unique, descriptive name for the Monitor in the Name field.
- Choose whether to automatically add the new Monitor to a particular Group.
- Check the Enabled checkbox.
- Choose whether you want the Monitor to Store Monitor Statistics for Recent Activity and Historical Reports.
Test Parameters

- Specify the Executable Name (in this case, sem_check.exe).
- Enter the Directory where the executable is located.
|
TIP
If using Windows 2000, the directory to enter would be c:\winnt\system32.
|
- In the Command Line Parameters field, enter the path to the file on the remote server using the following format:
\\remote server\logs\taskfile.txt
- Enter the Startup Directory. This is the directory where the executable will run.
- Select or create a Credential for Monitoring. The Credential should reference the account that has read+ permissions for the file.
Analysis of Test Results

- Configure the External Process Monitor to Compare the Process Return Value.
- The expected result is determined to be 0, indicating that the file being monitored is less than 24 hours old.
Timing and Notification Control
ipMonitor's flexible timing parameters provide the ability to intensify or lessen testing during each of a Monitor's four testing states: Up , Warn, Down and Lost. The Notification Control section determines how many test failures must occur before an Alert is sent, as well as the maximum number of Alerts that will be sent.
The timing parameters outlined below are recommendations only. You may have to alter them to suit your network environment.

- Enter the desired Maximum Test Duration. If a response is not returned within the defined number of seconds, the test fails.
- Enter the desired number of seconds between each Test while the Monitor is in an Up (or OK) state. (In this example, we have configured the Monitor to test every 24 hours)
- Enter the desired number of seconds between each Test while the Monitor is in a Warn state (a problem has been detected). Alerts are not processed during the Warn state.
- Enter the desired number of seconds between each Test while the Monitor is in a Down state (a failure has been confirmed). Alerts are processed during the Down state.
- Enter the desired number of seconds between each Test while the Monitor is in a Lost state (the resource continues to be down and the maximum number of Alerts has been processed). No further Alerts will be processed until the Monitor recovers.
- In the Accumulated Failures per Alert filed, enter the number of test failures that must occur before an Alert is generated for the Monitor.
- In the Maximum Alerts to Send field, enter the maximum number of Alerts to generate before the Monitor enters a Lost state.
Configuring the ipMonitor Utilities to Work with your Task's Timing Parameters
The example outlined in this tutorial is based on a task scheduled to run every 24 hours. However, the utilities provided are flexible, allowing you to adapt them to multiple scenarios.
If you run the ipMonitor utilities without any switches, you will be presented with the options available for each. For some scenarios, both utilities need to be used with a switch.
To monitor a task scheduled to run every hour:
- Configure the batch file to create a file that is "stale" (expired) right now:
sem_stamp.exe -addhours 0 c:\logs\taskfile.txt
- The External Process Monitor should then be configured to invoke the sem_check.exe tool using command line parameters formatted as shown below:
\\servername\logs\taskfile.txt -margin -3600
Note: The margin is calculated in seconds, therefore 60 x 60 = 3600
This setup will allow the file to be stale for no more then 60 minutes. If the 60-minute time period is exceeded, the Monitor will fail. Please note that you will also have to adjust the timing parameters of the Monitor to have it poll at least once every hour.
To monitor a task scheduled to run every week:
- Configure the batch file to create a file that will become "stale" (expire) in 7 days:
sem_stamp.exe -addhours 168 c:\logs\taskfile.txt
There is no need to use a switch with the sem_check.exe utility, however, the timing parameters for the External Process Monitor need to be adjusted so that the Monitor only checks the file once a week.
To monitor a task scheduled to run every month:
- Configure the batch file to create a file that will become "stale" (expire) in 31 days:
sem_stamp.exe -addhours 744 c:\logs\taskfile.txt
There is no need to use a switch with the sem_check.exe utility, however, the timing parameters for the External Process Monitor need to be adjusted so that the Monitor only checks the file once a month.
|
TIP
You may want to consider implementing a Maintenance Schedule in order to have the External Process Monitor enabled only once a month, or once a week, as needed.
|
Additional Information
For more information regarding the External Process Monitor, refer to the Monitors section of ipMonitor's Context-Sensitive Help system, then select Monitor Types, followed by External Process. The Context-Sensitive Help can be accessed by clicking the Help link located in the top right corner of ipMonitor's Administration web interface.
< Back

Last Updated: April 4, 2006 | What did you think of this topic?