#this script will work but is not as accurate as /var/adm/scripts/NIS_activity_log.sh #or /var/adm/scripts/activity_log.sh (for non-NIS machines) #this file will examine when the last activity of a user is #written by John Meissner on 4/23/2002 BOLD="`tput smso`" NORMAL="`tput rmso`" if [ `id|cut -c5-11` != "0(root)" ] then echo "Quitting - You must run this script as Root" exit 1 fi ################################# setting up variables ############################ month=$(date | awk '{print $2}') Jan=1 Feb=2 Mar=3 Apr=4 May=5 Jun=6 Jul=7 Aug=8 Sep=9 Oct=10 Nov=11 Dec=12 ############################## running script #################################### if [ $month = Jan ] then mdate=$Jan elif [ $month = Feb ] then mdate=$Feb elif [ $month = Mar ] then mdate=$Mar elif [ $month = Apr ] then mdate=$Apr elif [ $month = May ] then mdate=$May elif [ $month = Jun ] then mdate=$Jun elif [ $month = Jul ] then mdate=$Jul elif [ $month = Aug ] then mdate=$Aug elif [ $month = Sep ] then mdate=$Sep elif [ $month = Oct ] then mdate=$Oct elif [ $month = Nov ] then mdate=$Nov elif [ $month = Dec ] then mdate=$Dec fi ((mdate2=$mdate-1)) if [ $mdate2 = 1 ] then month2=Jan elif [ $mdate2 = 2 ] then month2=Feb elif [ $mdate2 = 3 ] then month2=Mar elif [ $mdate2 = 4 ] then month2=Apr elif [ $mdate2 = 5 ] then month2=May elif [ $mdate2 = 6 ] then month2=Jun elif [ $mdate2 = 7 ] then month2=Jul elif [ $mdate2 = 8 ] then month2=Aug elif [ $mdate2 = 9 ] then month2=Sep elif [ $mdate2 = 10 ] then month2=Oct elif [ $mdate2 = 11 ] then month2=Nov elif [ $mdate2 = 0 ] then month2=Dec fi find /home -name .sh_history | awk '{print "ll " $1}' > /tmp/hist chmod +x /tmp/hist echo "${BOLD} Most recent user login activity shown ${NORMAL}" echo "${BOLD} User Month Date Time ${NORMAL}" /tmp/hist | awk '{print $3 " " $6 " " $7 " " $8}' | grep -v $month | grep -v $month2 >> /tmp/hist.log more /tmp/hist.log rm /tmp/hist rm /tmp/hist.log