Re: Check when a user last logged in?



Assasin.x@xxxxxxxxx typed (on Thu, Aug 07, 2008 at 04:18:40PM -0700):
| I'm trying to make a script that will remove/point out or delete old
| user accounts. The problem is, I have no idea how to check when a
| user last logged in!
|
| Checking the modification date of the home folder will not work
| because there are many users that use the same home folder. I had
| heard SCO has some sort of built in way of checking for this, or that
| there is a unix command that can do it.
|
| Anybody out there able to help me out?
|
| Thanks in advance!

Overkill:

#!/bin/ksh
###---------------------------------------------------------------------
user="logname_here" # Needed if executed from cron
LoginLog="/tmp/LoginLog" # Keep a log here
[ -t 1 ] && { echo "Last Login for User: \c" ; read user ; } ;
grep ${user} /etc/passwd > /dev/null 2>&1
case $? in
0) set `last ${user} | head -2 | tail -1` > /dev/null 2>&1
[ -t 1 ] && { echo "Last login for User ${1}: $5 $6 $7 $8" ; } ;
echo "Last login for User ${1}: $5 $6 $7 $8" >> ${LoginLog}
;;
*) [ -t 1 ] && { echo "No User ${user}" ; } ;
echo "No User ${user}" >> ${LoginLog}
;;
esac
###---------------------------------------------------------------------

.



Relevant Pages

  • Check when a user last logged in?
    ... I'm trying to make a script that will remove/point out or delete old ... user accounts. ... Checking the modification date of the home folder will not work ...
    (comp.unix.sco.misc)
  • Re: Check when a user last logged in?
    ... | I'm trying to make a script that will remove/point out or delete old ... | because there are many users that use the same home folder. ...
    (comp.unix.sco.misc)
  • Re: Check when a user last logged in?
    ... | | | because there are many users that use the same home folder. ... | Since the original poster is looking for "old user accounts", ...
    (comp.unix.sco.misc)
  • Re: Check when a user last logged in?
    ... | I'm trying to make a script that will remove/point out or delete old ... | because there are many users that use the same home folder. ...
    (comp.unix.sco.misc)
  • Need help
    ... v-dashe wrote: ... According to the description, you want a logon script to map drive letters ... How to assign a home folder to a user ...
    (microsoft.public.windows.server.migration)