linux/Tip
로그인 사용자 명령 저장
efrit
2019. 12. 17. 13:38
#vi /etc/profile
function history_to_syslog {
declare CMD
CMD=$(history 1)
USER=`who am i`' : '$LOGNAME
logger -p local6.notice -- SESSION = $$, WHO = $USER, CMD = $CMD
}
trap history_to_syslog DEBUG
#vi /etc/rsyslog.conf
local6.notice /var/log/history_cmd.log
#systemctl restart rsyslog
#vi /etc/logrotate.d/history_cmd
/vat/log/history_cmd.log
{
monthly
rotate 12
missingok
notifempty
create
postrotate
systemctl restart rsyslog
endscript
}
#logrotate -f /etc/logrotate.d/history_cmd