The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to read record by record from a file in unix raoscb UNIX for Dummies Questions & Answers 1 05-16-2008 06:30 AM
splitting a record and adding a record to a file rsolap Shell Programming and Scripting 1 08-13-2007 01:58 PM
an hour less in 24 hour system bobo UNIX for Dummies Questions & Answers 3 10-23-2006 11:55 AM
Run job for a period of time cooldude Shell Programming and Scripting 5 03-06-2006 01:53 PM
Timeout period Nadeem Mistry UNIX for Dummies Questions & Answers 4 08-15-2001 09:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-08-2005
csaunders csaunders is offline
Registered User
  
 

Join Date: Sep 2003
Location: Arlington, VA
Posts: 160
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 (permalink)  
Old 12-09-2005
aniseed's Avatar
aniseed aniseed is offline
Registered User
  
 

Join Date: Dec 2005
Location: Mumbai, India
Posts: 23
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.
  #3 (permalink)  
Old 12-09-2005
csaunders csaunders is offline
Registered User
  
 

Join Date: Sep 2003
Location: Arlington, VA
Posts: 160
sweet thatnks! I will try this.
  #4 (permalink)  
Old 12-09-2005
csaunders csaunders is offline
Registered User
  
 

Join Date: Sep 2003
Location: Arlington, VA
Posts: 160
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 (permalink)  
Old 12-09-2005
dangral dangral is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2002
Posts: 699
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 (permalink)  
Old 12-09-2005
csaunders csaunders is offline
Registered User
  
 

Join Date: Sep 2003
Location: Arlington, VA
Posts: 160
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!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0