Operating System - HP-UX
1829323 Members
2082 Online
109989 Solutions
New Discussion

Any way to fix corrupted $HISTORY file?

 
Jorge Fabregas
Regular Advisor

Any way to fix corrupted $HISTORY file?

Hello all,

I changed root's default home (/) to (/root). It seems that in the process my $HISTORY file ($HOME/.sh_history) got corrupted. Everytime I do (su -) I get a core dump and I can't use the root account. I need to "su" root without the dash (so it won't run the .profile).

I had months of HISTORY there and I don't want to loose it. I still can see the contents of the file but as you many know this is not a 100% ASCII file so I can't know for sure what line is corrupted. I don't want to loose my HISTORY. Any way to make it work again?

thanks,
Jorge Fabregas
3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: Any way to fix corrupted $HISTORY file?

Actually, .sh_history is an ascii text file, I just checked on a D320 with 11i on it.

All you need to do is go to the new home directory and do this:

touch .sh_history

make sure permissions are -rw-r--r-- and that root owns it and its part of sys group.

chown root:sys .sh_history

Make sure the HISTFILE variable is correct in .profile and or /etc/profile and you are done.

solution.

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
Jorge Fabregas
Regular Advisor

Re: Any way to fix corrupted $HISTORY file?

Hi,

That doesn't work. The $HISTORY file is not really an ASCII file. (even though it looks like one). There are some special characters there. Check this thread:

http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x316a0ea029a2d711abdc0090277a778c%2C00.html&admit=716493758+1065214841083+28353475


thanks,
Jorge
Jeff Schussele
Honored Contributor

Re: Any way to fix corrupted $HISTORY file?

Hi Jorge,

Believe you may be out of luck here.
I've never seen one "restored" properly.
As Bill hints, it's probably by design.
You could set up a cron to copy it off with a date/time stamp periodically....

Rgds,
Jeff


PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!