标签:mat 操作记录 user root 记录 date chown file hostname
####################################################################################
history
USER_IP=$(who am i 2>/dev/null | awk ‘{print $NF}‘ | sed -e ‘s/[()]//g‘)
if [ "$USER_IP" = "" ];then
USER_IP=`hostname`
fi
if [ ! -d /tmp/user_history ];then
mkdir /tmp/user_history
chown root.root /tmp/user_history
chmod 777 /tmp/user_history
chattr +a /tmp/user_history
fi
if [ ! -d /tmp/user_history/${LOGNAME} ];then
mkdir -p /tmp/user_history/${LOGNAME}
fi
export HISTTIMEFORMAT=‘%F %T ‘
export HISTSIZE=‘40960‘
time=$(date ‘+%Y%m%d-%H:%M:%S‘)
export HISTFILE="/tmp/user_history/${LOGNAME}/${USER_IP}[$time]"
chmod 600 /tmp/user_history/${LOGNAME}/*history* 2>/dev/null
####################################################################################
标签:mat 操作记录 user root 记录 date chown file hostname
原文地址:http://www.cnblogs.com/louxindong/p/6216836.html