####################################################################################
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
####################################################################################

相关文章:

  • 2021-10-09
  • 2021-11-24
  • 2021-11-13
  • 2018-09-25
  • 2020-10-17
  • 2021-10-16
  • 2021-11-02
猜你喜欢
  • 2021-10-03
  • 2021-10-03
  • 2021-09-21
  • 2021-12-08
  • 2021-12-24
  • 2021-10-03
  • 2019-12-20
相关资源
相似解决方案