Script to report linux login yesterday

Create a script for yesterday.. yesterday.sh

#jmazaredo 4-19-2016
#Get the date month and date cut the necessary date 
ystd=$(date --date yesterday | cut -d' ' -f2,3) tdy=$(date --date today | cut -d' ' -f2,3)
#show the date yesterday Month and date 
echo ${ystd} #show the date today Month and date echo ${tdy}
#grep the date try checking the tdy since you may have no login yesterday 
last | grep "$tdy"

Crontab Entry
email it
  • 8 * * * /user/yesterday.sh | mail -s "Last Login Yesterday" me@example.net

Comments

Popular posts from this blog

Black screen after logging in on Windows 2012 R2 using domain credentials on remote desktop connection

Water Wonder Resort

Client denied by server configuration error