Login Check
From Braindisconnect
Jump to navigationJump to search
This is a check to see if anyone has logged into the machine in the last 30 days. Obviously if you login to the machine and run it, it will defeat the purpose. The is meant to be ran as a cron job once a week or even every day.
DAYS=30 for (( i=0; i<=$DAYS; i++)) ;do unset GREP unset DATE DATE=`date +'%b %d' -d "$i day"` GREP=`lastlog | grep "$DATE"` if [[ ! -z "$GREP" ]]; then break fi done if [[ -z "$GREP" ]]; then echo "Activity within 30 Days NOT Detected" fi ### DEBUG #if [[ ! -z "$GREP" ]]; then # echo "Activity within 30 Days Detected" #fi