Few days back I was working on some task and as a part of that I was required to run some command line utility. Now condition was to keep running that utility all the time and for whatever reasons it crashes it should start by itself.
Now, I could do it by creating another application or service which monitors this utility all the time and if it crashes, this service or monitoring app restarts that utility. But I thought it is more work just for a simple task. Instead I chose a different and easy approach. I created a batch file that runs in infinite loop and made this utility run inside that loop. For sake of some history I also added a log for each restart event. And that’s it !!
I am posting my script below (of course it is not original script but it is nearly as original)
@echo off set /a a = 1 :Begin echo %a% set /a a = %a% + 1 PING 22.214.171.124 -n 1 -w 5000 >NUL GoTO :Begin
Unfortunately I didn’t find any command that can make WAIT in DOS so instead I have used PING as a kind of work around. But hey if it solves my issue, then I have no complaints
That’s it for now …
It’s Just A Thought …