Question

I have got a number of batch scripts that we are currently running manually on local machines. I am planning to move these scripts onto our windows 2003 server and set up an automated task using the scheduler to run them every 4 hours.

I have no issues setting this up but the only reason we are doing this manually at the moment is in case the batch does not finish.

Is there a way to have the scheduler check if the batch has finished running and if it has not to run another event?

I imagine it might need some kind of time frame, say if it has not finished within 1 hour to report a problem as sometimes the scripts can take a long time.

Any advice on a better solution or if this is possible is greatly appreciated.

Thanks, Simon

Edit:

Added batch related tags, as I am doing this all via Batch files another option could be to add some code in my scipts that checks the runtime and reports an error and terminates if it was been running for say 2 hours.

I however have no idea how to accomplish this, will do a google but if anyone knows a way this could be another option. I know I do have to post some code that I have tried first before asking a question for "what script" can I use so will try something out first.

Was it helpful?

Solution

Take a look to "expect" language. http://sourceforge.net/projects/expect/ This is a extension to tcl/tk and provide a lot of things which can perfectly be used to run automated tests or control (remote) scripts and applications.

The thing you do:

Write a script where you can do some actions like starting an application or a shell or run a batch. Then you have a loop which have pairs of expected inputs and actions which should be done if these inputs are catched. And there is also a timeout clause!

Expect itself runs on all platforms I know and the scripts are portable to all OS.

We use it to run telnet sessions, running apps and batches and monitor the reactions of the DUT via serial/usb/network links. It is very flexible and easy to use. We also use expect as master script for a lot of gtest based unit tests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top