how do you monitor the progress of a command line program?

1

We have some custom command line programs at our Windows shop. These commands are scheduled to run (from within bat files) at regular intervals using the Task Scheduler. Our tasks pull data from other systems and shuffling information in files through bins used to manage our workflow. Sometimes a task runs long -- really long -- and it leaves us wondering if the console app is actually doing work or if it's hung somehow. (These apps communicate over the network with other applications.) Anyhow, I'm wondering if there's a way to tell whether the app is doing something or if it's idle. It's dangerous to our processing to kill such a task midstream, but we do have to kill a process if it's just going to remain hung to allow other work through. (Maybe a file lock might cause this, I dunno.)

I realize we could add logging to our individual apps but I'm hoping to find a solution that can be composed (piped) somehow -- for example, by maybe piping our STDIN/OUT through another monitoring console app. Is this reasonable? Is there something like this on either Unix or Windows?

customcmd | monitor "progress.txt" --label customcmd < customdata.txt > result.txt 2> error.txt

And maybe the progress.txt looks something like this:

5:01:10pm - customcmd - 20 reads, 20 writes
5:01:15pm - customcmd - 11 reads, no writes

Mario

Posted 2014-01-10T19:42:23.783

Reputation: 437

Did you ever find a solution to this? – EJoshuaS - Reinstate Monica – 2018-04-25T18:33:45.427

That process got retired so not an issue. However, one easy solution would be to write to a log (like the Windows event log), which we have since done for other processes. You can then stream events through PowerShell if needed. – Mario – 2018-04-26T14:20:38.600

PowerShell provides a mechanism for displaying progress bars that can work here. – Mario – 2018-04-26T14:23:00.830

If you are piping STDIN/STDOUT anyway, why not just pipe them to a file directly? And then use (for example on Linux) tail -f file1 -f file2 -f file 3 to track all 3 files on the same window. There is also a Unix package (supposedly runs on Cygwin as well) called multitail which divides the window up for each log. Or you can write a program that collects and process your logs. – Peon – 2014-01-10T20:14:27.347

What is "hung" in your definition? What is running in fact? Cmd/PowerShell/bash/your application? Solutions may vary... – Maximus – 2014-01-11T09:30:32.100

No answers