Login Check: Difference between revisions

From Braindisconnect
Jump to navigationJump to search
(Created page with "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 t...")
 
No edit summary
 
Line 1: Line 1:
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.
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.


<pre>
<pre>

Latest revision as of 15:42, 25 February 2016

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