Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
last login time
# Marnin, RU ITS, version .1, 11-2014
# Source:
echo "Check the last login time for an account"
echo "Enter the NetID to check:"
read user
# entire log of login info
# /usr/bin/syslog -F raw -k Facility | grep $user
# just the epoch time
lastlogin=`/usr/bin/syslog -F raw -k Facility | grep $user | awk '{ print $4 }' | sed -e 's/]//g' | tail -1`
# The date is displayed as the epoch time. You can also convert to normal time with
converttime=`date -r $lastlogin '+%m/%d/%Y:%H:%M:%S'`
echo "Last login for $user on $hostname was $converttime"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.