vi /etc/profile
export HISTORY_FILE=/var/log/usermonitor.log
export PROMPT_COMMAND='{ date "+%y-%m-%d %T ##### $(who am i |awk "{print \$1\" \"\$2\" \"\$5}") #### $(history 1 | { read x cmd; echo "$cmd"; })"; } >>$HISTORY_FILE'
suse系统可执行:
export HISTORY_FILE=/var/log/usermonitor.log
export PROMPT_COMMAND='{ date "+%y-%m-%d %T ##### $(who am i |awk "{print \$1\" \"\$2\" \"\$5}") #### $(history 1 | { read x cmd; echo "$cmd"; })"; } >>$HISTORY_FILE'
source /etc/profile
vi /var/log/usermonitor.log
chmod 777 /var/log/usermonitor.log
本文转自flayber 51CTO博客,原文链接:http://blog.51cto.com/406647516/1748823,如需转载请自行联系原作者