Bash command log ¸¸µé±â

   Á¶È¸ 8430   Ãßõ 1    

https://www.ehostidc.co.kr/ (344)
https://www.ehostidc.co.kr/cscenter/consulting.php (314)

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 24/28
2022-04   9045   µö·¯´×¼­¹ö
2020-08   9034   µö·¯´×¼­¹ö
2021-11   9024   µö·¯´×¼­¹ö
2022-01   8991   È­Á¤Å¥»ï
2019-02   8980   Á¶ÀÌÄÄÁ¤°ü½Ä
2020-06   8950   FOXBI
2019-03   8859   »ïÀ°°ø¾ßµå
2022-03   8851   ¹ÌÄ£°¨ÀÚ
2022-03   8847   È­Á¤Å¥»ï
2021-12   8843   È­Á¤Å¥»ï
2020-06   8709   ĵÀ§µå
2021-11   8706   µö·¯´×¼­¹ö
2020-08   8670   Tails
2020-10   8636   ÀÎõIº£¸®
01-11   8623   µö·¯´×¼­¹ö
2019-10   8587   °£Àå°ÔÀå
2020-09   8582   ½Å¿µÁø
2020-10   8497   ¾Ç¸¶¶ó³×
2020-02   8490   ȲÁø¿ì
2020-12   8482   Äðº¸ÀÌ