Step 1:
/etc/bashrc 파일 마지막 라인에 다음 사항 추가
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "[$(whoami)][$PWD][$$]: $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" ) [$RETRN_VAL]"'
Step 2:
/etc/syslog.config 파일에 다음사항 추가
local6.* /var/log/cmdlog.log
syslog 재시작
#> service syslog restart
출력예:
Jan 26 22:31:32 localhost root: [root][/root][12547]: tail -f /var/log/messages [130]
Jan 26 22:31:45 localhost root: [root][/root][12547]: vi /etc/syslog.conf [0]
Jan 26 22:44:19 localhost root: [root][/root][12547]: source /etc/bashrc [0]
Jan 26 22:44:20 localhost root: [root][/root][12547]: ll [0]
Jan 26 22:44:21 localhost root: [root][/root][12547]: ls -la [0]
Jan 26 22:44:23 localhost root: [root][/root][12547]: pwd [0]
Jan 26 22:49:05 localhost root: [root][/root][2646]: vi /etc/bashrc [0]
Jan 26 22:31:45 localhost root: [root][/root][12547]: vi /etc/syslog.conf [0]
Jan 26 22:44:19 localhost root: [root][/root][12547]: source /etc/bashrc [0]
Jan 26 22:44:20 localhost root: [root][/root][12547]: ll [0]
Jan 26 22:44:21 localhost root: [root][/root][12547]: ls -la [0]
Jan 26 22:44:23 localhost root: [root][/root][12547]: pwd [0]
Jan 26 22:49:05 localhost root: [root][/root][2646]: vi /etc/bashrc [0]
"프로그래밍 / Linux & Shell Script" 분류의 다른 글
[shell script] bash read command (0) | 2014/02/11 |
[linux] Linux Console에서 BEEP 사운드 끄기 (0) | 2014/01/27 |
[shell] netstat (0) | 2014/01/22 |
[shell script] 배열(Array) 사용하기 (0) | 2014/01/10 |
[shell script] 함수(Function) 사용하기 (0) | 2014/01/09 |
[linux] 메모리 (0) | 2013/12/17 |
[shell script] Here Documents (0) | 2013/11/26 |
[shell script] directory exists check (0) | 2013/11/20 |
[shell script] 실행 경로 구하기 (0) | 2013/10/24 |
[shell] yum 장애 조치 (0) | 2009/04/21 |