dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

want to find the users who have not logged in from past 60 days - aix

This is a discussion on want to find the users who have not logged in from past 60 days - aix ; Hi, Would like to write a script to find the users who have not logged in from the past 60 days.. We have AIX 5.3........ any inputs plz? Thanks...


Home > Database Forum > Operating Systems > aix > want to find the users who have not logged in from past 60 days

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 11-13-2008, 12:43 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default want to find the users who have not logged in from past 60 days

Hi,

Would like to write a script to find the users who have not logged in
from the past 60 days.. We have AIX 5.3........ any inputs plz? Thanks
Reply With Quote
  #2  
Old 11-13-2008, 01:12 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: want to find the users who have not logged in from past 60 days

rak пишет:
> Hi,
>
> Would like to write a script to find the users who have not logged in
> from the past 60 days.. We have AIX 5.3........ any inputs plz? Thanks


AIX it's powerful OS.
You can find information about last login on file `/etc/security/lastlog'

For example:

admin:
time_last_login = 1226593857
tty_last_login = /dev/pts/0
host_last_login = admin.office
unsuccessful_login_count = 0

--
UV-RIPE
Reply With Quote
  #3  
Old 11-13-2008, 01:41 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: want to find the users who have not logged in from past 60 days

On Nov 13, 9:12*am, Vladimir Usenko wrote:
> rak пишет:
>
> > Hi,

>
> > Would like to write a script to find the users who have not logged in
> > from the past 60 days.. We have AIX 5.3........ any inputs plz? Thanks

>
> * AIX it's powerful OS.
> * You can find information about last login on file `/etc/security/lastlog'
>
> * For example:
>
> admin:
> * * * * *time_last_login = 1226593857
> * * * * *tty_last_login = /dev/pts/0
> * * * * *host_last_login = admin.office
> * * * * *unsuccessful_login_count = 0
>
> --
> UV-RIPE


is there any ready-made script or any ideas in writing such?
Reply With Quote
  #4  
Old 11-13-2008, 02:13 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: want to find the users who have not logged in from past 60 days

On Nov 13, 6:41 pm, rak wrote:
> On Nov 13, 9:12 am, Vladimir Usenko wrote:
>
>
>
> > rak пишет:

>
> > > Hi,

>
> > > Would like to write a script to find the users who have not logged in
> > > from the past 60 days.. We have AIX 5.3........ any inputs plz? Thanks

>
> > AIX it's powerful OS.
> > You can find information about last login on file `/etc/security/lastlog'

>
> > For example:

>
> > admin:
> > time_last_login = 1226593857
> > tty_last_login = /dev/pts/0
> > host_last_login = admin.office
> > unsuccessful_login_count = 0

>
> > --
> > UV-RIPE

>
> is there any ready-made script or any ideas in writing such?


lsuser -a id ALL | awk '{ print $(NF-1) }' |\
while read user ; do
lssec -f /etc/security/lastlog -s "$user" -a time_last_login
done

man lsuser
man lssec

hth
Hajo
Reply With Quote
  #5  
Old 11-13-2008, 05:36 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: want to find the users who have not logged in from past 60 days

On Nov 13, 10:13*am, Hajo Ehlers wrote:
> On Nov 13, 6:41 pm, rak wrote:
>
>
>
>
>
> > On Nov 13, 9:12 am, Vladimir Usenko wrote:

>
> > > rak пишет:

>
> > > > Hi,

>
> > > > Would like to write a script to find the users who have not logged in
> > > > from the past 60 days.. We have AIX 5.3........ any inputs plz? Thanks

>
> > > * AIX it's powerful OS.
> > > * You can find information about last login on file `/etc/security/lastlog'

>
> > > * For example:

>
> > > admin:
> > > * * * * *time_last_login = 1226593857
> > > * * * * *tty_last_login = /dev/pts/0
> > > * * * * *host_last_login = admin.office
> > > * * * * *unsuccessful_login_count = 0

>
> > > --
> > > UV-RIPE

>
> > is there any ready-made script or any ideas in writing such?

>
> *lsuser -a id *ALL | awk '{ print $(NF-1) }' |\
> * while read user ; do
> * * *lssec -f /etc/security/lastlog -s "$user" -a time_last_login
> * done
>
> man lsuser
> man lssec
>
> hth
> Hajo- Hide quoted text -
>
> - Show quoted text -



I got this script, which looks good

#!/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

any comments??
Reply With Quote
  #6  
Old 11-13-2008, 06:48 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: want to find the users who have not logged in from past 60 days

day=
now=$( date +%s ) # Number since epoch
expired=$(($now-86400*$days))




Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 03:18 AM.