record wc -l over 24 hour period

I need to keep track of this output

echo "dis chs(*)" | runmqsc | grep RUNNING | wc -l

I need to record that count once an hour 24 hours a day and write to a file with the date and time it was run. Any idea on how to do this.

A simple way is to execute the command in a while loop from a script and sleep for one hour (3600 seconds).

#!/usr/bin/ksh
while true 
do
	echo "dis chs(*)" | runmqsc | grep RUNNING | wc -l
	# Sleep for one hour
	sleep 3600
done

Redirect the output of the script to a file.

You could add a "echo date" inside to print the timestamp. :slight_smile:

sweet thatnks! I will try this.

wait, im not following the "echo date". Wont this output just "date".
And if I do another pipe i.e.

echo "dis chs(*)" | runmqsc | grep RUNNING | wc -l | date
Fri Dec 9 11:21:08 EST 2005

I dont get the wc -l

any ideas?

The "date" should be a separate statement before you command. so it would look like:

#!/usr/bin/ksh
while true 
do
	date
        echo "dis chs(*)" | runmqsc | grep RUNNING | wc -l
	# Sleep for one hour
	sleep 3600
done

Of course you would want to redirect the output of the script to a file.

yep luckily i figured this out! thanks guys!