HTML Code
archive_history() { HISTORYOLD=${HISTFILE}.archive CURTIME=`date` CURTTY=`tty` IP=$(echo $SSH_CLIENT | awk '{print $1}') if [ x$HISTDUMPPED = x ]; then echo "#-${HOSTNAME}-- ${CURBASHDATE} - ${CURTIME} ($CURTTY) ${USER} ${IP}----" >> $HISTORYOLD history $(($HISTCMD-${CURBASHSTART-0})) | sed -e 's/^[ ]*[0-9][0-9]* [ ]*//g' >> $HISTORYOLD export HISTDUMPPED=1 fi } exit () { archive_history builtin exit }
then add following line in .bash_logout in each user home's dir.
vi /home/oracle/ .bash_logout
archive_history >> .bash_logout
you can see all details by like " command date ipaddress/username"
after doing above all step once login, run some command and then logout and then login
and then check "cat .bash_history.archive"
with your script i am getting output like this :
cat /home/oracle/.bash_history.archive
#-test2.fatima-group.com-- - Thu Mar 27 17:38:23 PKT 2014 (/dev/pts/2) oracle 10.1.8.226----
2014-03-27 17:38:23 logout
#-test2.fatima-group.com-- - Thu Mar 27 17:41:11 PKT 2014 (/dev/pts/4) oracle 10.1.8.244----
2014-03-27 17:41:11 logout
#-test2.fatima-group.com-- - Thu Mar 27 17:52:02 PKT 2014 (/dev/pts/3) oracle 10.1.8.226----
2014-03-27 17:52:02 logout
There are 2 problems , i mean which i want to fulfill my requirement
Problem 1 : i am not getting command which is executed by user
problem2 : i should get all details in .bash_history.archive even if i close my terminal ( i mean i just close my ssh terminal and dont type exit or logout )
thanks in advance