record wc -l over 24 hour period


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting record wc -l over 24 hour period
# 1  
Old 12-08-2005
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.
# 2  
Old 12-09-2005
A simple way is to execute the command in a while loop from a script and sleep for one hour (3600 seconds).
Code:
#!/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. Smilie
# 3  
Old 12-09-2005
sweet thatnks! I will try this.
# 4  
Old 12-09-2005
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?
# 5  
Old 12-09-2005
The "date" should be a separate statement before you command. so it would look like:

Code:
#!/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.
# 6  
Old 12-09-2005
Quote:
Originally Posted by dangral
The "date" should be a separate statement before you command. so it would look like:

Code:
#!/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!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Disk usage monitoring and record the disk used in last 24 hour

HI I am Trying to edit the below code to send email every day with difference of disk utilized in for last 24 hours but instead getting same usage everyday. can you please help me to point out where my calculation is going wrong. Thank you. ================= #!/bin/bash TODAY="at $(date... (0 Replies)
Discussion started by: Mi4304
0 Replies

2. Shell Programming and Scripting

Need code for updating second record to first record in shell scripting

Hi,, I have requirement that i need to get DISTINCT values from a table and if there are two records i need to update it to one record and then need to submit INSERT statements by using the updated value as a parameter. Here is the example follows.. SELECT DISTINCT ID FROM OFFER_GROUP WHERE... (1 Reply)
Discussion started by: Samah
1 Replies

3. Shell Programming and Scripting

Replace a string for every record after the 1st record

I have data coming in the below format for each record <?xml version="1.0" encoding="UTF-8" standalone="no"?><test_sox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><testdetials>....</test_sox> <?xml version="1.0" encoding="UTF-8" standalone="no"?><test_sox... (8 Replies)
Discussion started by: dsravanam
8 Replies

4. Shell Programming and Scripting

Extract timestamp from first record in xml file and it checks if not it will replace first record

I have test.xml <emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp> <Join><id>101</id><city>london</city><date>06/06/14 2011</date></join> <Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join> <Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies

5. Shell Programming and Scripting

How to compare current record,with next and previous record in awk without using array?

Hi! all can any one tell me how to compare current record of column with next and previous record in awk without using array my case is like this input.txt 0 32 1 26 2 27 3 34 4 26 5 25 6 24 9 23 0 32 1 28 2 15 3 26 4 24 (7 Replies)
Discussion started by: Dona Clara
7 Replies

6. Shell Programming and Scripting

How to convert 24 hour time to 12 hour timing?

Hi friends, I want to convert 24 hour timing to 12 hour please help me... my data file looks like this.. 13-Nov-2011 13:27:36 15.32044 72.68502 13-Nov-2011 12:08:31 15.31291 72.69807 16-Nov-2011 01:16:54 15.30844 72.74028 15-Nov-2011 20:09:25 15.35096 ... (13 Replies)
Discussion started by: nex_asp
13 Replies

7. Shell Programming and Scripting

Reject the record if the record in the next line does not begin with 2.

Hi, I have a input file with the following entries: 1one 2two 3three 1four 2five 3six 1seven 1eight 1nine 2ten 2eleven 2twelve 1thirteen 2fourteen The output should be: (5 Replies)
Discussion started by: supchand
5 Replies

8. Shell Programming and Scripting

Reject the record if the record in the next line does not satisfy the pattern

Hi, I have a input file with the following entries: 1one 2two 3three 1four 2five 3six 1seven 1eight 1nine 2ten The output should be 1one 2two 3three 1four 2five 3six (2 Replies)
Discussion started by: supchand
2 Replies

9. Shell Programming and Scripting

counting word xx referred to a time period, like minute or hour

Hello, I try to insert a post because I've got a trouble to perform a unix job. But I didn't found which steps (procedure) I should follow. Could you help me? I got a log by my Application box, like following: gbosmam037:test >view Log_Server.csv ... (2 Replies)
Discussion started by: maluca68
2 Replies

10. UNIX for Dummies Questions & Answers

an hour less in 24 hour system

My program: __________________________________ #!/bin/ksh DAY=`date +%y%m%d` H=`date +%H` M=`date +%M` day=`date +%m/%d/%y` let h=$H-1 echo DAY $DAY echo H $H echo M $M echo day $day echo h $h _____________________________________ My result: (3 Replies)
Discussion started by: bobo
3 Replies
Login or Register to Ask a Question