[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] [RaQ4] CPU Usage ?



>Anyway of checking this afterwards ??
>I don't wanne stare at the active monitor all day long

I've been wanting to do a similar thing lately (there seems an occasional lag in opening files on a windows machine via samba, and i wondered if the server was busy at the time.. another time for that one), so I created my first little bash script and added it to Cron. It seems to work really well :-)))))))) <enormous grin for my personal achievement in linux!>

First, [well, after spending several hours trawling the internet] I created a file called uptime_log (I found that entering "touch uptime_log" did the trick).

Then created two text files using pico

<file uptimelogscript>
#!/bin/sh
uptime >> /home/users/admin/uptime_log
</end of file>

<file uptimelogscript_date>
#!/bin/sh
date >> /home/users/admin/uptime_log
</end of file>

Then set the scripts to be executable by typing:
chmod 755 uptimelogscript_date
chmod 755 uptime_log

Then I created a set of crontab entries looking like so...

0 * * * * /home/users/admin/uptimelogscript
10 * * * * /home/users/admin/uptimelogscript
20 * * * * /home/users/admin/uptimelogscript
30 * * * * /home/users/admin/uptimelogscript
40 * * * * /home/users/admin/uptimelogscript
50 * * * * /home/users/admin/uptimelogscript
1 1 * * * /home/users/admin/uptimelogscript_date

This all works to send the results from the command "uptime" to the uptime_log file. the script is called by Cron every 10 minutes in my case. I quickly lost track of which day was which, so the uptimelogscript_date script is run once a day, first thing in the morning. The uptime result goes on a new line every time by itself, which is why I couldn't just use the date>>/home... command in front of every line created.

To read the log file I use "cat uptime_log | more"

I hope this helps,
Steve
www.rootskitchens.co.uk