Operating System - HP-UX
1823251 Members
3328 Online
109648 Solutions
New Discussion юеВ

Re: Session level history to be enabled instead of user level.

 
SOLVED
Go to solution
Pradeep_3
Frequent Advisor

Session level history to be enabled instead of user level.

Hello

I have HP-UX 11.11. Presently our history file is generated on user level. Is there any way I can get session level history?

Thanks in advance
Paresh Kalathia
4 REPLIES 4
Ramkumar Devanathan
Honored Contributor

Re: Session level history to be enabled instead of user level.

truncate .sh_history everytime you login.

add the following in your .profile -

> ~/.sh_history
# EOF

- ramd.
HPE Software Rocks!
Pradeep_3
Frequent Advisor

Re: Session level history to be enabled instead of user level.

Ram

what if I am logging in using same username on different terminals at the same time? I will be having multipal sessions at the same time, so when ever I will run some command,it will update my history file and if I press Esc+k even from other session, I will get same command from history file. What if I want to avoid this?

Paresh
Stefan Farrelly
Honored Contributor
Solution

Re: Session level history to be enabled instead of user level.

To avoid sharing a history file then create a unique history file per user per session based on date+time, this is what we do, eg. in .profile;

HISTFILE=${HOME}/.history_files/.hist.`who am i|awk '{print $1}'`.$$.`date +%d%m%y.%H%M`
Im from Palmerston North, New Zealand, but somehow ended up in London...
Pradeep_3
Frequent Advisor

Re: Session level history to be enabled instead of user level.

you right stephen that is correct method, but I added following in my /etc/profile which writes hist files with session pid and tty as an extension. So that I can do audit for each and every session.

tty1=`who am i|awk '{print $2}'`
tty=`basename $tty1`
pid1=`ps |grep sh | awk '{print $1}'`
pid=`echo $pid1 | awk '{print $1}'`
echo $pid.$tty
export HISTFILE=$HOME/hst/.parlog.$pid.$tty

Any way thanks for giving very good suggestion.