I need a KornShell script that will, among all the users currently logged on to the system, find a slot of one hour that contains the most number of users. I know how to list all the users currently logged on but how do I do anything with the times that are listed?
Have your script run in a loop and run the following -- date and 'w'.
Exit your script after you are done collecting your metrics. Write another little script to parse the output and create a pretty chart.
Here is a short script that may help.
It is very simplistic and you can concatenate the echo output to a log file if you wish.
#!/bin/ksh
eval `date '+hour=%H minute=%M second=%S'`
end_hr=`expr ${hour} + 1`
end_time="${end_hr}:${minute}:${second}"
until [ -z ${now_time} -eq ${end_time} ]
do
now_time=`date +%H:%M:%S`
numr=`who | wc -l`
echo "${numr} users are logged on at ${now_time}"
sleep 60
done
Quick Links:
Do you have
a UNIX Question?
Unix Home: Unix System Administration
Hints and Tips