improve sulog

I just wrote a very small script that improves readability on system sulog. The problem with all sulog is there is lack of clarity whether the info you are looking at is the most current. So if you just need a simple soution instead of going thru the trouble of writing a script that rotate logs and figure out number of days on the time stamp or install a program to do it, just grep on the fly for what is important that you want like ???-root or ???-oracle and append the system timestamp into the sulog for historical future references.

while true
do
  TODAY=`date`
  LASTROOT=`tail -1 ./sulog | grep "\-root" > /tmp/testroot`
  if [[ -s /tmp/testroot ]] then
    echo "found :- `tail -1 ./sulog`" | mailx -s "list of users su - root" sparcguy@admin.com
    echo $TODAY >> ./sulog
  else
    echo "not found"
  fi
  sleep 1
done
1 Like