User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 391,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,544 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 3608 | Replies: 2
Reply
Join Date: May 2006
Posts: 2
Reputation: mattlock73 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mattlock73 mattlock73 is offline Offline
Newbie Poster

Simple script loop question

  #1  
May 16th, 2006
Hey all. Thanks in advance for any help you can give, hopefully this is an easy one. I want to create a loop to run a simple performance monitor like vmstat and record it to a file, but have very limited scripting skills.

Starting with this...

date >> /var/log/perfmon.log
vmstat 3 10 >> /var/log/perfmon.log

I basically want it to sleep for 5 minutes using sleep 300, but how do I start the process again (restart the loop)?

Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2006
Location: India
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: Simple script loop question

  #2  
May 17th, 2006
while true
do
date >> /var/log/perfmon.log
vmstat 3 10 >> /var/log/perfmon.log
sleep 300
done

but instead of giving a sleep of 5 minutes why don't you cron the whole thing. Schedule the commands so that they run after every 5 min.

Amit
Reply With Quote  
Join Date: May 2006
Posts: 2
Reputation: mattlock73 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mattlock73 mattlock73 is offline Offline
Newbie Poster

Re: Simple script loop question

  #3  
May 17th, 2006
Originally Posted by kamitsin
while true
do
date >> /var/log/perfmon.log
vmstat 3 10 >> /var/log/perfmon.log
sleep 300
done

but instead of giving a sleep of 5 minutes why don't you cron the whole thing. Schedule the commands so that they run after every 5 min.

Amit

Originally that's what I was going to do, however the particular box I am trying to get this running on has had cpu spike issues that cause crons to fail during the spikes. Hoping that an active process may have more luck staying active than a new process starting. Am also going to collect data for a specific interval, write to file then tar the files by date/time. Wasn't sure how to do that by cron. Anyway, got it working the way I wanted it until the real scripting guy gets back from vacation thanks!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Shell Scripting Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 9:08 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC