天天看點

history編寫

vim /etc/profile

export HISTORY_FILE=/tmp/history/`date +%Y%m%d`-history.log

if [ ! -f /tmp/history/`date +%Y%m%d`-history.log ]; then

        mkdir -p /tmp/history

        chmod 777 -R /tmp/history

        touch /tmp/history/`date +%Y%m%d`-history.log

        chmod 777 /tmp/history/`date +%Y%m%d`-history.log

fi

export PROMPT_COMMAND='{ date "+%Y-%m-%d %T  $(who am i |awk "{print \$1\" \"\$2\" \"\$5}") $(id | awk "{print \$1}") $(pwd | awk "{print \$1}") # $(history 1 | { read x cmd; echo "$cmd"; })"; } >> $HISTORY_FILE'

本文轉自leonardos51CTO部落格,原文連結:http://blog.51cto.com/leomars/1614717 ,如需轉載請自行聯系原作者