Re: Old user list

From: Chladek, Dave (Dave.Chladek_at_NHMCCD.EDU)
Date: 07/28/04

  • Next message: Naylor, Jim: "Re: F40 Service Processor ???"
    Date:         Wed, 28 Jul 2004 14:06:17 -0500
    To: aix-l@Princeton.EDU
    
    

    Here is a cool utility to convert time...

    http://www.unixreview.com/documents/s=1344/ur0307g/ur0307g_script.htm

    ... and the following is an unmodified script I picked up from
    somewhere, but I don't remember where, and between the two scripts you
    should be able to work out your question and probably one or two others
    you have not asked...

    #!/usr/bin/ksh
    #set -x

    #Try this script.
    #It will check and lock the accounts automatically for those logins that
    #have not been used to s set number of days.

    expdays=90 #<< ---- Set number of days in past here!
    let expiry=86400*$expdays
    locked=" "
    tmp1=/tmp/exp.tmp1.$$
    tmp2=/tmp/exp.tmp2.$$
    tmp2a=/tmp/exp.tmp2a.$$
    tmp3=/tmp/exp.tmp3.$$
    tmp4=/tmp/exp.tmp4.$$

    # List all users that are allowed to login
    lsuser -a login account_locked time_last_login ALL |grep -Ev
    ^"root|daemon|bin|sys|adm|nobody" | grep "login=true" > $tmp1

    # get all users who have logged in at least once with login date
    grep 'time_last_login' $tmp1 | sed -e 's/login=true //' -e
    's/account_locked=//' -e 's/time_last_login=//' >$tmp2

    # get all users who have not logged in since creation
    grep -v 'time_last_login' $tmp1 | sed -e 's/login=true //' -e
    's/account_locked=//' >$tmp2a

    # get today's date in seconds from epoch for comparison
    year=`date +%Y`
    day=`date +%j`
    hour=`date +%H`
    minute=`date +%M`

    let today="($year - 1970) * 365 * 86400 + ($day - 1) * 86400 + $hour *
    3600 + $minute * 60 + ($year - 1969) / 4 * 86400"

    # for each user found, check whether has not been unused too long
    cat $tmp2 |while read user locked last
    do
            let min=$today-$expiry
            if [[ $min -gt $last ]]
            then
                    let login="($today - $last) / 86400"
                    echo $user':'$login':'$locked >> $tmp4
                      #chuser shell='/usr/local/bin/locked'
                            #account_locked='true' $user
            fi
    done

    HTH,
    Dave Chladek

    -----Original Message-----
    From: IBM AIX Discussion List [mailto:aix-l@Princeton.EDU] On Behalf Of
    Zebrouvis, Lois
    Sent: Wednesday, July 28, 2004 1:24 PM
    To: aix-l@Princeton.EDU
    Subject: Re: Old user list

    lsuser -a time_last_login userid (or ALL)
    The time is in seconds from Jan 1st 1970

    -----Original Message-----
    From: Robert Miller [mailto:rmiller@SMUD.ORG]
    Sent: Wednesday, July 28, 2004 2:04 PM
    To: aix-l@Princeton.EDU
    Subject: Re: Old user list

    The quickest way to see when a person last logged on would be 'last -1
    <username>' - that will give you one line detailing when they last
    logged in. However, if the /var/adm/wtmp file gets truncated on a
    regular basis, say through a cron job, it's only as good as the first
    date of the wtmp file. To see the last entry (and thus the earliest
    date), use 'last | tail -1', which will just give you the last line of
    the "last" output (excuse the pun ;) )

    The wtmp file is the only place I know of that has stored login info...

    --rm

    -----Original Message-----
    From: IBM AIX Discussion List [mailto:aix-l@Princeton.EDU]On Behalf Of
    Hass, Harold
    Sent: Wednesday, July 28, 2004 10:42 AM
    To: aix-l@Princeton.EDU
    Subject: Old user list

    I'm sure it's been answered before, and probably is in the archives, but
    I can't find it!

    How can I produce a list of users that have not logged in for a period
    of time, say 8 months?

    AIX 4.3.3 - AIX 5.2

    TIA Harold Hass


  • Next message: Naylor, Jim: "Re: F40 Service Processor ???"

    Relevant Pages

    • Re: Old user list
      ... and the following is an unmodified script I picked up from ... lsuser -a login account_locked time_last_login ALL |grep -Ev ... The wtmp file is the only place I know of that has stored login info... ... TIA Harold Hass ...
      (AIX-L)
    • Re: Hacker activity?
      ... >login to a server, most as root but some are attempts to login to ... >telnet, all come from the same remote server, and all fail. ... >getting some odd cgi calls to a script on a secure ssl server. ... Make sure root cannot login to your system via ssh. ...
      (freebsd-questions)
    • Re: [opensuse] BASH: has $COLUMNS gone nuts?
      ... You do realize that lines & columns are dynamic values which at least some terminals and login daemons will continuously adjust right? ... What the above shows is that I dragged the corner of my PuTTY window (which was connected to sshd, not every terminal client nor every server daemon does this) making the window a little larger and without issuing any commands, and no possibility that any bashrc or inclusions got executed, the values changed, because the terminal told the daemon and the daemon told it's child processes. ... Try calling them from within a script: ... Although, I would also actually be perverse and say that since the SCO systems predate most others, including ALL linux, that you could actually make the argument that the dwindling remaining production sco boxes in the world are right and the 90 million linux & freebsd & sun boxes are all wrong. ...
      (SuSE)
    • Abusing poor programming techniques in webserver scripts V 1.0
      ... $login = Request.Form ... fool the database parser. ... verified in the script of access to the database, ... The SQL statement will be parsed by the database manager, ...
      (SecProg)
    • Re: Limit desktop & start menu
      ... Create a login script that runs when users log into the TS, and map the R: ... persisitent "R" drive on the server itself and that may cure it. ...
      (microsoft.public.windows.terminal_services)