Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write unix script for vmstat

Status
Not open for further replies.

narri

MIS
Nov 11, 2002
4
US
Hi,
I want to write a unix script for vmstat every 10 Seconds .
In the Progrmme the code will be vmstat 10
I want to save it to a file.
I think we can give a parameter for example TWO Hours.
Thanks a lOt for your help.

Nan.
 
Hi,

iribach is right, best way to use crontab with deriving the output to file e.g. vmstat >file 2>/dev/null
cheers
Uwe
 
**Korn Shell
LOOPCT=0
vmstat 600 |& # coprocess resample every 10 minutes
while read -p # while the coprocess if running
do
echo $REPLY
LOOPCT=$(($LOOPCT+1))
if [$LOOPCT -gt "50")
then
exit 0
fi
done

If you alter the loop count and vmstat seconds you can collect data for weeks at a time. This works the same for other similar utilities like netstat, etc. The first data line in the file should be disregarded as it is cumulative since the machine was rebooted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top