---
title: "How to monitor the time duration of a batch job using State Tracker and Compute Engine"
description: "Monitoring batch job duration uses State Tracker and Compute Engine features in Geneos. State Tracker tracks job states while Compute Engine calculates start time, end time, and duration using custom rules."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004022705-geneos-how-to-monitor-the-time-duration-of-a-batch-job-using-state-tracker-and-compute-engine/index.html"
---
**You can use the State Tracker plugin and the Compute Engine feature to monitor the duration of a job.**

The [State Tracker](https://docs.itrsgroup.com/docs/geneos/current/collection/state-tracker/index.html) plug-in can be used to look for a particular sequence of keywords or entries in a log file. Therefore if your batch job writes out to a consistent log, and you can identify selected entries and link them to particular stages in the batch job, you can track progress in the batch job.  The below State Tracker dataview monitors a batch job that writes to /tmp/batchrun.log. This dataview has states: "Job Running" and "Job Completed." The initial state is set to "Initializing" as seen below.  ![Screenshot](https://docscdn.itrsgroup.com/faq/images/geneos/115004022705-inline-1-mceclip1.png)  Notice the State Tracker plug-in on its own will not provide the start time, completion time, or duration of the batch job. To do this, the [Compute Engine](https://docs.itrsgroup.com/docs/geneos/current/processing/monitoring-and-alerts/geneos_rulesactionsalerts_tr/index.html#Compute_Engine) functionality is needed to create additional headlines cells and column to populate this data.  Below are the headline and column names that will be added to the Batch Run dataview:  ![Screenshot](https://docscdn.itrsgroup.com/faq/images/geneos/115004022705-inline-2-mceclip3.png)  To populate these new additions, the following three rules can be used (one for each cell to track the current state and copy the time).  The "start time" rule will be used to populate the "Last Job Started" headline cell:  ![Screenshot](https://docscdn.itrsgroup.com/faq/images/geneos/115004022705-inline-3-mceclip4.png)  The "end time" rule will be used to populate the "Last Job Ended" headline cell:  ![Screenshot](https://docscdn.itrsgroup.com/faq/images/geneos/115004022705-inline-4-mceclip5.png)  Once the job is complete, the third rule will then compute for the duration of the start and the end time and set the value in the "Duration" column:  ![Screenshot](https://docscdn.itrsgroup.com/faq/images/geneos/115004022705-inline-5-mceclip6.png)  Below is the State Tracker dataview now displaying the duration of the batch job:  ![Screenshot](https://docscdn.itrsgroup.com/faq/images/geneos/115004022705-inline-6-mceclip7.png)  To try this example, please refer to the below attachments:  The **rules\_jobduration.xml**contains the code for the above rules.  The **sampler\_jobduration.xml**contains the code for the State Tracker sampler.

## Related downloads

- [sampler_jobduration.xml](/faq/downloads/geneos/115004022705-6979024906525-sampler_jobduration.xml)
- [rules_jobduration.xml](/faq/downloads/geneos/115004022705-6979024907037-rules_jobduration.xml)


