Last active
March 7, 2017 13:59
-
-
Save gaoxt/0c95e9a74e74efe64fbf4f640a5065fc to your computer and use it in GitHub Desktop.
history command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#vi /etc/profile >> | |
#history | |
USER_IP=`who -u am i 2>/dev/null | awk '{print $NF}' | sed -e 's/[()]//g'` | |
HISTDIR=/usr/share/.history | |
if [ -z $USER_IP ]; then | |
USER_IP=`hostname` | |
fi | |
if [ ! -d $HISTDIR ]; then | |
mkdir -p $HISTDIR | |
chmod 777 $HISTDIR | |
fi | |
if [ ! -d $HISTDIR/${LOGNAME} ] | |
then | |
mkdir -p $HISTDIR/${LOGNAME} | |
chmod 300 $HISTDIR/${LOGNAME} | |
fi | |
export HISTSIZE=4000 | |
DT='date + %Y%m%d_%H%M%S' | |
export HISTFILE="$HISTDIR/${LOGNAME}/${USER_IP}.history.$DT" | |
export HISTTIMEFORMAT="[%Y.%m.%d %H:%M:%S]" | |
chmod 600 $HISTDIR/${LOGNAME}/*.history* 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment