Bash command log ¸¸µé±â

   Á¶È¸ 8924   Ãßõ 1    

https://www.ehostidc.co.kr/ (395)
https://www.ehostidc.co.kr/cscenter/consulting.php (365)

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 8/28
2020-02   11901   ÅëÅë9
2020-01   11921   ¸¸¼®±º
2014-07   11956   user
2020-06   11971   ¸ÞÆ®
2013-12   12055   ºü½Ã¿Â
2016-03   12126   ĵÀ§µå
2022-03   12169   µö·¯´×¼­¹ö
2016-06   12194   ¹«¾Æ
2020-05   12274   ³«¿±À̽½1
2015-08   12310   QS¿ÕÅëÅ°¼Õ¡¦
2021-04   12386   È­Á¤Å¥»ï
2011-08   12402   ÀüÁ÷P¿¬±¸¿ø
2018-08   12437   °õÅÊÀ̾ƺü
2022-05   12504   theÃ̳ð
2013-11   12597   ȲÁø¿ì
2020-12   12616   ¹Ú¹®Çü
2021-03   12619   ³ª¿ì¼Ò·¡
2016-07   12680   ȲÁø¿ì
2016-07   12707   isaiah
2022-04   12726   ±èȲÁß