标签:记录每个用户的操作
#1.Mail partial configuration,set /etc/mail.rc #2.Below is the main configuration cat >>/etc/profile<<Share #Variables LAST_USER=`last -n 2 |awk ‘NR==2{print $1}‘` LOG_FILE_PATH="/tmp/Shared_Operation" LAST_FILE_LOG=`ls -tl ${LOG_FILE_PATH}/${LAST_USER} |awk -F‘[ ]‘ ‘NR==2{print $(NF-0)}‘` USER_IP=`who -u am i 2>/dev/null| awk ‘{print $NF}‘|sed -e ‘s/[()]//g‘` #Mail Send to Admin mail -s "The last time $LAST_USER from $USER_IP, the operating information" < ${LOG_FILE_PATH}/${LAST_USER}/${LAST_FILE_LOG} if [ "$USER_IP" = "" ] then USER_IP=`hostname` fi if [ ! -d ${LOG_FILE_PATH} ] then mkdir $LOG_FILE_PATH chmod 707 $LOG_FILE_PATH fi if [ ! -d ${LOG_FILE_PATH}/${LOGNAME} ] then mkdir ${LOG_FILE_PATH}/${LOGNAME} chmod 4700 ${LOG_FILE_PATH}/${LOGNAME} fi export HISTSIZE=4096 DT=`date "+%F_%T"` export HISTFILE="${LOG_FILE_PATH}/${LOGNAME}/${USER_IP}_$DT" chmod 600 ${LOG_FILE_PATH}/${LOGNAME}/*lige* 2>/dev/null Share
本文出自 “甲乙丙” 博客,请务必保留此出处http://51inte.blog.51cto.com/4403468/1696640
标签:记录每个用户的操作
原文地址:http://51inte.blog.51cto.com/4403468/1696640