#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

 

참조 :  https://lklingling.tistory.com/106

Posted by efrit
,