Running SAR command in the background forever

Hi Experts,

Below is the command issued on SUSE LINUX 11 server to run in the background in order to collect the performance data.

sar 60 > sar.output 2>&1 &

When I looked at the output(sar.output) after 10 hours, it logged only 180 entries which is equivalent to 3 hours of run. I could not see any sar process running in the background. The above command should run continuously without any interruption. Why did the process got aborted after certain period of time. Please help.

Thanks,
PrabAsh
PrabAshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Zephyr ICTCloud ArchitectCommented:
I think if you use the interval switch it runs as a background process continously ... Not sure, been a while.
Something like:

sar -o datafile interval count >/dev/null 2>&1 &

Open in new window


Like this all data is captured in binary and saved to a file (datafile), this data can be selectively displayed with the the -f option.  If the count parameter is not used, all the data saved in the file will be selected, using it this way you can characterize system usage over a period of time, it should run continuously like this... I haven't tested it beyond an hour at the most though...
0
robocatCommented:
There's a much better way to do this using cron and the sa1 sa2 commands:

# vi /etc/cron.d/sysstat
*/1 * * * * root /usr/local/lib/sa/sa1 1 1
53 23 * * * root /usr/local/lib/sa/sa2 -A

This will log the stats each minute into a file  /var/log/sa/saXX file. (XX is the day of the month)

Using "sar" without time options will show the SAR data for the current day, or use with -f option for another dat

Eg.

sar
sar -f /var/log/sa/sa29
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.