메뉴 닫기

커맨드 로그만들기

vi /etc/profile

##CMD_LOG######################################################
function history_to_syslog {
declare command
remoteaddr=”`who am i`”
pwd=”`pwd`”
command=$(fc -ln -0)
if [ “$command” != “$old_command” ]; then
logger -p local2.notice -t bash -i ? “$USER : $remoteaddr” “Command : $command Directory : $pwd”
fi
old_command=$command
}
trap history_to_syslog DEBUG
###############################################################

맨아래 위 코드 입력 후 syslog 또는 rsyslog (사용중인 로그에 입력)

vi /etc/syslog.conf

local2.notice /home/yongwoo/cmd.log

 

source /etc/profile

/etc/init.d/syslog restart

적용 및 재구동 시키고 해당 위치에 보면 로그 생성이 됩니다

[polldaddy rating=”7739789″]

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x