#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
H
I
S
T
D
I
R
/
HISTDIR/
HISTDIR/{LOGNAME} ]
then
mkdir -p
H
I
S
T
D
I
R
/
HISTDIR/
HISTDIR/{LOGNAME}
chmod 300
H
I
S
T
D
I
R
/
HISTDIR/
HISTDIR/{LOGNAME}
fi
export HISTSIZE=4000
DT=date +%Y%m%d_%H%M%S
export HISTFILE=“
H
I
S
T
D
I
R
/
HISTDIR/
HISTDIR/{LOGNAME}/
U
S
E
R
I
P
.
h
i
s
t
o
r
y
.
{USER_IP}.history.
USERIP.history.DT”
export HISTTIMEFORMAT=“[%Y.%m.%d %H:%M:%S]”
chmod 600
H
I
S
T
D
I
R
/
HISTDIR/
HISTDIR/{LOGNAME}/.history 2>/dev/null
Linux记录history命令
最新推荐文章于 2024-06-24 10:16:22 发布