AIX

Korn Shell 로그인 계정별 history 남기기

efrit 2010. 3. 16. 23:57

crfs -v jfs2 -g rootvg -a size=1G -m /hist
mount /hist
chmod 777 /hist

vi /etc/profile

### 계정별 history 남기기                     2010.03.15.  JY
TTY=`tty`
HISNAME=`basename $TTY`
IP=`who |grep pts/${HISNAME} |cut -f 2 -d \(|cut -f 1 -d \)`
LOGIN_ID=`/bin/logname`
SU_ID=`/usr/bin/whoami`
JOB_TIME=`date +%y%m%d_%H%M%S`
HISDIR=/hist
export HISTSIZE=10000

export HISTFILE=${HISDIR}/${JOB_TIME}_${IP}_${LOGIN_ID}_SU:${SU_ID}

chmod 755 /etc/profile


#### 참고 사이트
접속한 사용자별로 따로 shell history(날짜,시간포함) 를 따로 기록하기?
http://kldp.org/node/68579
http://www-903.ibm.com/kr/techinfo/pseries/aixnl109.html

-----------------------------------------------------------------------------
profile 에 설정해 syslog 로 넘기기

 function history_to_syslog
{
typeset cmd
cmd=$(history -0)
logger -t shellcmd[$$] -- USER=$LOGNAME, CWD=`pwd`, CMD=$cmd
}
trap history_to_syslog DEBUG || EXIT