Bash command log ¸¸µé±â

   Á¶È¸ 8313   Ãßõ 1    

https://www.ehostidc.co.kr/ (323)
https://www.ehostidc.co.kr/cscenter/consulting.php (298)

1) rsyslog 및 패키지 설치

root@localhost:[~]: yum install -y rsyslog rsyslog-doc -y


2) /etc/profile.d/ 내 스크립트 로그 작성

root@localhost:[~]: vi /etc/profile.d/log.sh

#!/bin/bash

function history_to_syslog {

  declare command;remote=`who am i|awk '{print $5}'`;command=`fc -ln -0|sed 's/\t //'`

  if [ $USER == "root" ];then located="$PWD]#";else located="$PWD]$";fi

  if [ "$command" != "$old_command" ]; then

    logger -p local3.notice -t bash -i "history2syslog: $USER$remote:$located $command"

  fi;old_command=$command

}

trap history_to_syslog DEBUG


3) 별도 파일 생성을 위한 rsyslog 수정

root@localhost:[~]: vi /etc/rsyslog.conf

*.info;mail.none;authpriv.none;cron.none;local3.none                /var/log/messages

local3.notice                                           /var/log/cmd


4) rsyslog 서비스 재시작 및 log 확인

root@localhost:[~]: service rsyslog restart

root@localhost:[~]: tail -f /var/log/cmd





https://www.aiocp.co.kr/ ( 딥러닝,머신러닝 서버 판매 ,컨설팅) https://bigbangcloud.co.kr/ ( GPU 클라우드 서비스) ::: AI 서버의 모든것 ::: 인공지능의 시작~ (주)이호스트ICT


Á¦¸ñPage 20/28
2016-05   19568   ²Ù¸®9
2016-05   17995   ±èȲÁß
2016-04   38698   isaiah
2016-04   22759   ¸ùź
2016-04   19748   俵Áø
2016-04   14644   izegtob
2016-04   19302   ´ëÀü»ç¶÷
2016-04   16036   ¹Ú¹®Çü
2016-04   20022   ´ëÀü»ç¶÷
2016-03   12434   ĵÀ§µå
2016-03   11626   ĵÀ§µå
2016-03   10424   ĵÀ§µå
2016-03   20052   ĵÀ§µå
2016-03   10853   ¾Æ½º¶õ
2016-03   18802   俵Áø
2016-03   16879   ¿¥ºê¸®¿À
2016-03   14989   °¡¸¸ÀÌÀ־
2016-03   22236   izegtob
2016-02   15920   ĵÀ§µå
2016-02   12314   ĵÀ§µå