Operating System - HP-UX
1748175 Members
4401 Online
108758 Solutions
New Discussion юеВ

Re: Shell history not being written to specified history file

 
Brett Simpson
Frequent Advisor

Shell history not being written to specified history file

I have been trying to create an alternative shell history file and my commands are not being written to it, but still to the .sh_history file. I've entered the following in my .profile:

HISTFILE=$HOME/.$LOGNAME"_history"
date>>$HISTFILE
#print -s "### login at `/usr/bin/date` ###"
export HISTFILE
HISTSIZE=500
export HISTSIZE

All I get in my history file is the date/time I log in:

Thu Apr 23 15:47:13 CDT 2009
Fri Apr 24 10:03:04 CDT 2009
Fri Apr 24 10:04:34 CDT 2009

All of the command history is still being stored in .sh_history.

Any ideas?
36 REPLIES 36
Steven E. Protter
Exalted Contributor

Re: Shell history not being written to specified history file

Shalom,

If the home directory is on NFS may not work.

I would try setting it this way:

HISTFILE="${HOME}/.${LOGNAME}_history"

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Pete Randall
Outstanding Contributor

Re: Shell history not being written to specified history file

Check your environment to make sure it's set as you think:

# env |grep HIST
HISTFILE=/tmp/.sh_history.root


Pete


Pete
Mark S Meadows
Valued Contributor

Re: Shell history not being written to specified history file

Hi Brett,

Try setting the variable in your home account .profile and logging out and back in again and you it should work ok :

vi .profile
~
~
alias checkfs='/home/markme/bin/monitor_fs/check_fs.sh'

HISTFILE=$HOME/.$LOGNAME"_history"
export HISTFILE
~
~

/home/markme# ls -ail .markme*
9381 -rw------- 1 markme users 48 Apr 24 16:53 .markme_history
gba70102:/home/markme#
Administrating HP-UX systems for more years than I care to admit, but still enjoying it (most of the time!).
Brett Simpson
Frequent Advisor

Re: Shell history not being written to specified history file

It's not an NFS-mounted directory - it's local.

Here's the output of env|grep HIST:

env|grep HIST
HISTFILE=/home/bsimpson/.bsimpson_history
HISTSIZE=500

Brett Simpson
Frequent Advisor

Re: Shell history not being written to specified history file

Mark,
I made the changes in my /home .profile
Mark S Meadows
Valued Contributor

Re: Shell history not being written to specified history file

Brett,

Sorry - I did not read the original posting thoroughly.

If you have logged logged out and back in again it should be working.

The variable is not set in the /etc/profile with a "readonly" against it, which would prevent it from being amended ?

Regards,

Mark
Administrating HP-UX systems for more years than I care to admit, but still enjoying it (most of the time!).
Brett Simpson
Frequent Advisor

Re: Shell history not being written to specified history file

Mark,
There's no reference to HISTFILE or any history in /etc/profile.

I agree that this should work, but can't figure out why it's not!
Pete Randall
Outstanding Contributor

Re: Shell history not being written to specified history file

Unless your shell doesn't invoke .profile?


Pete

Pete
Dennis Handly
Acclaimed Contributor

Re: Shell history not being written to specified history file

>All of the command history is still being stored in .sh_history.

Where are you defining HISTFILE? Near the top of your .profile?

I also use:
set -o nolog # don't save functions in history file