Append in/etc/profile
Export History_file=/var/log/history/userhistory.logreadonly prompt_command= ' {date ' +%y-%m-%d%T ##### $ (Who am I |awk " {print \$1\ "\" \$2\ "\" \ $NF} ") # # # # (Id|awk" {print \$1} ") # # # # (History 1 | {read x cmd; echo "$cmd";}) ";} >> $HISTORY _file '
Reread Source/etc/profile can take effect.
Mkdir-p/var/log/history/
Touch/var/log/history/userhistory.log
New configuration file in/etc/logrotate.d/userhistory
/etc/loratate.d/userhistory content is as follows
/var/log/history/userhistory.log {Weekly Notifempty prerotate/usr/bin/chattr-a/var/log/his Tory/userhistory.log Endscript Postrotate/bin/chmod 002/var/log/history/userhistory.log/usr /bin/chattr +a/var/log/history/userhistory.log Endscript}
This article is from the "New Lei blog" blog, make sure to keep this source http://helloeveryone.blog.51cto.com/6171143/1529723