記錄歷史記錄腳本

#!/bin/bash

history
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
if [ "$USER_IP" = "" ]
then
USER_IP=`hostname`
fi
if [ ! -d /tmp/oper_history ]
then
mkdir /tmp/oper_history
chmod 777 /tmp/oper_history
fi
if [ ! -d /tmp/oper_history/${LOGNAME} ]
then
mkdir /tmp/oper_history/${LOGNAME}
chmod 300 /tmp/oper_history/${LOGNAME}
fi
export HISTSIZE=4096
DT=`date "+%Y%m%d%H%M%S"`
export HISTFILE="/tmp/oper_history/${LOGNAME}/${USER_IP}_history$DT"
chmod 600 /tmp/oper_history/${LOGNAME}/*history* 2>/dev/null

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章