Bash command log ¸¸µé±â

   Á¶È¸ 10084   Ãßõ 1    

https://www.ehostidc.co.kr/ (464)
https://www.ehostidc.co.kr/cscenter/consulting.php (446)

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 9/28
2016-04   17532   ¹Ú¹®Çü
2015-05   19260   ÁÒ¯
2015-05   14492   ±èȲÁß
2015-05   35770   ÁÒ¯
2013-03   78240   ¾ÈÇü°ï
2016-04   24159   ĸƾ¾Æ¸Þ¸®Ä«³ë
2017-07   554861   ¼¼¹ú½­
2023-06   73063   µö·¯´×¼­¹ö
2016-10   15987   ¿¥ºê¸®¿À
2018-09   22124   ÇϾá°í´Ï
2014-01   38013   ȲÁø¿ì
2015-08   37720   witbox
2014-02   15169   ºü½Ã¿Â
2016-10   17954   stone92±è°æ¹Î
2014-02   11877   ºü½Ã¿Â
2014-02   16124   ºü½Ã¿Â
2016-11   29844   stone92±è°æ¹Î
2016-11   39840   stone92±è°æ¹Î
2016-06   13538   ȲÁø¿ì
2016-12   24808   QS¿ÕÅëŰ¼Õ¡¦