<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: .sh_history getting trimmed by itself ? Why ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627199#M236865</link>
    <description>Good One Geoff !!! will make use of the script. &lt;BR /&gt; I understand, using "print" command is problematic from within .profile but I see you use "print -s" commnd in your TimeStamp function. would that not chop off the history file again.</description>
    <pubDate>Thu, 15 Sep 2005 15:09:14 GMT</pubDate>
    <dc:creator>Sammy_2</dc:creator>
    <dc:date>2005-09-15T15:09:14Z</dc:date>
    <item>
      <title>.sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627186#M236852</link>
      <description>HPUX 11.11&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;root .profile has value set very high (see below)&lt;BR /&gt;=====================================&lt;BR /&gt;&lt;BR /&gt;HISTFILE=/root/.sh_history ; export HISTFILE&lt;BR /&gt;print -s "LOGIN - `date '+%m-%d-%E-%H:%M'`"&lt;BR /&gt;HISTSIZE=64000 ; export HISTSIZE&lt;BR /&gt;######################&lt;BR /&gt;BUT,&lt;BR /&gt;I see my root .sh_history file get trimmed by itself? It goes back to around just 120-180 commands. dont know why and dont see cron job doing it.&lt;BR /&gt;&lt;BR /&gt;For troubleshooting, I have a cron script which ll .sh_history every 5 minuts with date and wc -l of .sh_history . No fixed time happening. Why ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;See Below the log file. &lt;BR /&gt;1) Jul 19 (14:30) size was 4288 . 5 minutes later, it was 1546&lt;BR /&gt;2)Aug 31 (11:55) the size was 9478 and 5 minutes later the size was&lt;BR /&gt;1474. &lt;BR /&gt;&lt;BR /&gt;=======================================&lt;BR /&gt;Tue Jul 19 14:30:00 EDT 2005&lt;BR /&gt;302&lt;BR /&gt;-rw-------   1 root       sys           4288 Jul 19 12:08 /root/.sh_history&lt;BR /&gt;=======================================&lt;BR /&gt;Tue Jul 19 14:35:00 EDT 2005&lt;BR /&gt;130&lt;BR /&gt;-rw-------   1 root       sys           1546 Jul 19 14:31 /root/.sh_history&lt;BR /&gt;=======================================&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;========================================&lt;BR /&gt;Wed Aug 31 11:55:00 EDT 2005&lt;BR /&gt;662&lt;BR /&gt;-rw-------   1 root       sys           9478 Aug 31 09:19 /root/.sh_history&lt;BR /&gt;=======================================&lt;BR /&gt;Wed Aug 31 12:00:00 EDT 2005&lt;BR /&gt;132&lt;BR /&gt;-rw-------   1 root       sys           1474 Aug 31 11:57 /root/.sh_history&lt;BR /&gt;=======================================&lt;BR /&gt;Any Ideas ? If not , I need to modify script so&lt;BR /&gt;I compare CUR_SIZE of .sh_history to PREV_SIZE file of when the cron was run 5 minutes ago. If CUR_SIZE is Smaller than PREV_SIZE, send me a page. I have the gist of it down below but have trouble comparing and storing PREV_SIZE variable.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Need to modify &lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;CUR_SIZE=`ll .sh_history | awk '{print $5}'`&lt;BR /&gt;if [ $CUR_SIZE -lt $PREV_SIZE ];then&lt;BR /&gt;mailx -s "SIZE CHANGED" pager@abc.com&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So, when I get page, i can get on the system and look at cron and other logs.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 15 Sep 2005 12:06:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627186#M236852</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-09-15T12:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627187#M236853</link>
      <description>The HISTSIZE variable is set by default to 128 and limits the number of commands in the HISTFILE to that.  You can set the HISTFILE parameter in your profile to retain more if needed.</description>
      <pubDate>Thu, 15 Sep 2005 12:12:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627187#M236853</guid>
      <dc:creator>Alan Meyer_4</dc:creator>
      <dc:date>2005-09-15T12:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627188#M236854</link>
      <description>oops, nevermind...  you already new that...  sorry</description>
      <pubDate>Thu, 15 Sep 2005 12:13:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627188#M236854</guid>
      <dc:creator>Alan Meyer_4</dc:creator>
      <dc:date>2005-09-15T12:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627189#M236855</link>
      <description>is the root account shared?&lt;BR /&gt;&lt;BR /&gt;this could be a reason.</description>
      <pubDate>Thu, 15 Sep 2005 12:17:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627189#M236855</guid>
      <dc:creator>Florian Heigl (new acc)</dc:creator>
      <dc:date>2005-09-15T12:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627190#M236856</link>
      <description>I wonder if 64000 is too big. Maybe the number is converted to a 32 bit integer, which 64000 would be 0xFA00 (a negative number) and the system defaults to 128?&lt;BR /&gt; &lt;BR /&gt;But if it is changing later, maybe you have a cron job that does some sort of cleanup process and shrinking the .history file is one of its tasks.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 15 Sep 2005 12:21:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627190#M236856</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-09-15T12:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627191#M236857</link>
      <description>No, root is not shared. And just for grins, I have change HISTSIZE=2000. Anyway, how could I modify the script to do CUR_SIZE /PREV_SIZE comparison ?&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 15 Sep 2005 12:27:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627191#M236857</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-09-15T12:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627192#M236858</link>
      <description>Make the following change-&lt;BR /&gt; &lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;. /tmp/PREVSIZE&lt;BR /&gt;CUR_SIZE=`ll .sh_history | awk '{print $5}'`&lt;BR /&gt;if [ $CUR_SIZE -lt $PREV_SIZE ];then&lt;BR /&gt;mailx -s "SIZE CHANGED" pager@abc.com&lt;BR /&gt;fi&lt;BR /&gt;echo "export PREV_SIZE=$CUR_SIZE" &amp;gt;/tmp/PREVSIZE&lt;BR /&gt; &lt;BR /&gt;This will retain the PREV_SIZE in a temp file for later fetching.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 15 Sep 2005 12:35:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627192#M236858</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-09-15T12:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627193#M236859</link>
      <description>Hi Sammy,&lt;BR /&gt;While you are fighting with this stange situation (no its nothing to do with too big I just checked:$ wc -l .sh_history&lt;BR /&gt;16361 .sh_history)&lt;BR /&gt;I would add a cron that makes copie regularly (very) size wont help in undestanding what is going on the countent maybe... Are you sure you have clowns out there that can do a su root of some sort and that would like to remove evidences...?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;All the best&lt;BR /&gt;Victor&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Sep 2005 12:40:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627193#M236859</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2005-09-15T12:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627194#M236860</link>
      <description>I think I locked out those clowns after SOX made us restrict access to just true Sys admins. Actually, i am seeing similiar behavior on some other hp servers as well but other like one below this has a huge history file.Thats what i want. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ROOT:S41:/ ==&amp;gt; ll .sh*&lt;BR /&gt;-rw-------   1 root       sys          83362 Sep 15 12:29 .sh_history&lt;BR /&gt;&lt;BR /&gt;and see same HIST variables.&lt;BR /&gt;# HISTFILE=$HOME.sh_history&lt;BR /&gt;HISTFILE=/.sh_history&lt;BR /&gt;HISTSIZE=64000&lt;BR /&gt;print -s "LOGIN - `date '+%m-%d-%E-%H:%M'`"&lt;BR /&gt;export  HISTFILE HISTSIZE               # &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Sep 2005 12:46:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627194#M236860</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-09-15T12:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627195#M236861</link>
      <description>It's the print -s&lt;BR /&gt;&lt;BR /&gt;I've had problems with that myself....&lt;BR /&gt;&lt;BR /&gt;Sometimes it blanks it out....don't know why....&lt;BR /&gt;&lt;BR /&gt;If you have multiple admins, do this to setup multiple sh_histories:&lt;BR /&gt;&lt;BR /&gt;# Set up logging&lt;BR /&gt;HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`&lt;BR /&gt;export HISTFILE&lt;BR /&gt;print -s "### login at `/usr/bin/date` ###"&lt;BR /&gt;HISTSIZE=50000&lt;BR /&gt;export HISTSIZE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Sep 2005 12:53:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627195#M236861</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-09-15T12:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627196#M236862</link>
      <description>Geoff,&lt;BR /&gt;That may make sense but this thing is so darn random. &lt;BR /&gt;If print -s blanks it out, then I will not use and see if that makes a difference. How would I othewise insert date in the .sh_history file. just echo `date` &amp;gt;&amp;gt; /root/.sh_history thru cron will do it but is that advisable. I dont want to maintain separate history files as it is easier to peruse one file as we command recall each other commands.&lt;BR /&gt;&lt;BR /&gt;Thanks a bunch though. i will post to see if what you suggested works.</description>
      <pubDate>Thu, 15 Sep 2005 13:12:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627196#M236862</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-09-15T13:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627197#M236863</link>
      <description>Geoff, &lt;BR /&gt;you may be onto something (though not sure) because I saw another hp system which had huge history file but print command was commented out.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 15 Sep 2005 13:15:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627197#M236863</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-09-15T13:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627198#M236864</link>
      <description>Yes - I have also done it like this from cron:&lt;BR /&gt;&lt;BR /&gt;# cat /usr/local/bin/datestamp-root-history&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;#&lt;BR /&gt;# script to add a date stamp to the /.sh_history_$USER&lt;BR /&gt;# for those su'ed to root&lt;BR /&gt;# Only run from cron once a day&lt;BR /&gt;# gwild 2004-10-15 with help from jkittle&lt;BR /&gt;&lt;BR /&gt;#===================================================================&lt;BR /&gt;# initialize some variables&lt;BR /&gt;#===================================================================&lt;BR /&gt;ULOG=/tmp/datestamp-user.log&lt;BR /&gt;cat /dev/null &amp;gt; $ULOG&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#===========================================================&lt;BR /&gt;# Function:    TimeStamp&lt;BR /&gt;# Description: timestamp the /.sh_history_$USER&lt;BR /&gt;# Arguments:   none&lt;BR /&gt;# Returns:     none&lt;BR /&gt;#===========================================================&lt;BR /&gt;function TimeStamp {&lt;BR /&gt;  # point to their .sh_history file&lt;BR /&gt;  # time stamp it&lt;BR /&gt;  echo "HISTFILE is $HISTFILE"&lt;BR /&gt;  (export HISTFILE=${HOME}/.sh_history_$UNIQUSER; echo "HISTFILE is $HISTFILE"; print -s "### `/usr/bin/date` $UNIQUSER still logged in as root...###")&lt;BR /&gt;  unset HISTFILE&lt;BR /&gt;  echo "HISTFILE after unset is $HISTFILE"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#===================================================================&lt;BR /&gt;# BEGIN MAIN CODE&lt;BR /&gt;#===================================================================&lt;BR /&gt;&lt;BR /&gt;# find parent process of all users signed in as root&lt;BR /&gt;for i in `ps -ef |grep "\-sh"|awk '{print $3}'`&lt;BR /&gt;do&lt;BR /&gt;  # just grab the user name&lt;BR /&gt;  for USER in `ps -ef |grep $i |grep -v root|awk '{print $1}'`&lt;BR /&gt;  do&lt;BR /&gt;    echo $USER &amp;gt;&amp;gt; $ULOG&lt;BR /&gt;  done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;# get each user only once&lt;BR /&gt;for UNIQUSER in `cat $ULOG |sort|uniq`&lt;BR /&gt;do&lt;BR /&gt;  TimeStamp&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I'm pretty sure it is in the .profile that causes the issue - something to do with not being completely logged in or something - not too sure....&lt;BR /&gt;&lt;BR /&gt;Unfortunately, when you just do say:&lt;BR /&gt;&lt;BR /&gt;date &amp;gt;&amp;gt;$HISTFILE&lt;BR /&gt;&lt;BR /&gt;when you esc k - it proceeds the first command in your history file...ie - doesn't set a proper end of line????&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Sep 2005 13:40:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627198#M236864</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-09-15T13:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627199#M236865</link>
      <description>Good One Geoff !!! will make use of the script. &lt;BR /&gt; I understand, using "print" command is problematic from within .profile but I see you use "print -s" commnd in your TimeStamp function. would that not chop off the history file again.</description>
      <pubDate>Thu, 15 Sep 2005 15:09:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627199#M236865</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-09-15T15:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: .sh_history getting trimmed by itself ? Why ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627200#M236866</link>
      <description>So far I havn't had trouble with the cron job - doesn't mean it is guaranteed though!&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Thu, 15 Sep 2005 15:27:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sh-history-getting-trimmed-by-itself-why/m-p/3627200#M236866</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-09-15T15:27:57Z</dc:date>
    </item>
  </channel>
</rss>

