0

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

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by mattlock73
0

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

0

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!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.