If use bash script how to record the number of logged in users every 5 minutes. Each measurement needs to be appended to a text file. There should be one line of text for each measurement, formatted as follows.
Fri Oct 11 13:12:04 EDT 2011 8 users
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will count multiple logins of a single user as multiple matches i.e if you ssh into a machine 3 times with the same account this will show
3 usersecho $(date) $(who | awk '{print $1}' | wc -l) users >> log.txtTo treat multiple logins from one username as one match this is what you want:
echo $(date) $(who | awk '{print $1}' | uniq | wc -l) users >> log.txt