How many time have user logged last X days?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How many time have user logged last X days?
# 1  
Old 03-20-2009
How many times have user logged last X days?

Hi all..

I was trying to do a little shell script, that would list users and their login times, lets say like last 5 days.

But I couldnt figure out how to count users login times from previous days. Any tips?

Funny that nobody has do this kinda script before, or atleast I couldnt find on from anywhere.

-k-

Last edited by Kimmo_; 03-20-2009 at 09:02 AM..
# 2  
Old 03-20-2009
Maybe try moving this to the scripting section on the forum instead... will probably have better luck.

https://www.unix.com/shell-programming-scripting/
# 3  
Old 03-20-2009
First find out if you have a wtmp file and whether it contains the data you require and whether it is properly maintained or left to grow.
man wtmp .
ls -la /var/adm/wtmp
If you have not got a wtmp file, you cannot run the unix "last" command.
man last.

We archive our wtmp file weekly and keep a rolling 3 months. Some systems administrators just let the file grow. A wtmp which is more than one year old gives ambiguous results from "last" because "last" does not display the year. This can be fixed by pre-processing the file with fwtmp and sed.

To check the oldest date in your wtmp file.
cat /var/adm/wtmp|/usr/sbin/acct/fwtmp|head

In general it is easier to save statistics for a day on the day the event occurred. You could save a rolling 5 days of the output from last (for today only) at 23:59 daily. This is subject to having a suitable wtmp file in the first place.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

• Write a shell script that upon invocation shows the time and date and lists all the logged-in user

help me (1 Reply)
Discussion started by: sonu pandey
1 Replies

2. Shell Programming and Scripting

Script to find users not logged in for 90 days

Dear All, I need your help in finding out users not logged in to linux system for more than 90 days. I found a script from our forum i am getting error while using that. from the code i have debugged line by line to see where i am getting the problem. i found out the below line i am getting... (5 Replies)
Discussion started by: Sachinlinux
5 Replies

3. Red Hat

How to confirm an user logged in is a remote user?

How do I confirm if a user logged in, is remote or local? In the case if the user is remote, how to be sure what authentication/method is it using, like LDAP, NIS or other? (2 Replies)
Discussion started by: kirtikjr
2 Replies

4. Shell Programming and Scripting

Does running a cron job of a user require the user to be logged in?

Suppose user 'asdf' is not logged into server 'bbbb', but the server is up. User 'asdf' has cron job. Will it be executed? (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

5. Shell Programming and Scripting

Users not logged in for last 90 days

Hi, How to find the users who did not login into a UNIX box (thru ssh/ftp or any other way) for last 90 days? I think of using "finger" or "last" command to findout each user's last login and then find number of days between today and that day. Is there any other better way or anyone prepared... (1 Reply)
Discussion started by: reddyr
1 Replies

6. Shell Programming and Scripting

Shell script to display user logged last week and time connected

Hello all, I want to display all the user logged last week and know the time tnat they are connected. I have been looking for a solution in the Forum, but I didn't find. Thanks in advance (4 Replies)
Discussion started by: ahernandez
4 Replies

7. UNIX Desktop Questions & Answers

Shell script to display user logged in within given time

how can i know which users have logged in at specified given start and end time in 24 hour format? (3 Replies)
Discussion started by: meherzad4u
3 Replies

8. Shell Programming and Scripting

How can one know how much time user logged?

Hello, i know who command gives you the time when particular user logged in. And subtracting today's date and time from the one found in who we can get how much time user logged in. But this can get very much clumsy as we can't subtract date directly in unix . Is there any other way or command... (4 Replies)
Discussion started by: salman4u
4 Replies

9. Solaris

List all inactive users who has not logged on since last 90 days

I need actuall script which List all inactive users who has not logged on since last 90 days Thanks in advance. Di! (17 Replies)
Discussion started by: haridham
17 Replies

10. UNIX for Dummies Questions & Answers

List all inactive users who has not logged on since last 90 days

Hi, Can I get a script to list out all the users, who has not logged on since last 90 days. Last command in not working due due to /var/adm/wtmpx is more than 2 GB. Thanks in advance. Regards, Roni (10 Replies)
Discussion started by: manasranjanpand
10 Replies
Login or Register to Ask a Question