<?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: trim wtmp file by date in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321783#M187512</link>
    <description>echo "1=Jan\n2=Feb\n...12=Dec\n" &amp;gt; /tmp/temp.txt&lt;BR /&gt;&lt;BR /&gt;When you want to excecute it do&lt;BR /&gt;Current_month=`date "+%b"`&lt;BR /&gt;count=`grep "$Current_month" /tmp/temp.txt"|awk -F = '{print $1}'`&lt;BR /&gt;count3=`grep $(($count-3)) /tmp/temp.txt|awk -F = '{print $1}'`&lt;BR /&gt;count2=`grep $(($count-2)) /tmp/temp.txt|awk -F = '{print $1}'`&lt;BR /&gt;count1=`grep $(($count-1)) /tmp/temp.txt|awk -F = '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;fwtmp &amp;lt; /var/adm/wtmp &amp;gt; /tmp/wtmp.txt&lt;BR /&gt;egrep "$count3|$count2|$count1" /tmp/wtmp.txt |fwtmp -ic &amp;gt; /var/adm/wtmp&lt;BR /&gt;&lt;BR /&gt;Anil</description>
    <pubDate>Fri, 02 Jul 2004 10:28:22 GMT</pubDate>
    <dc:creator>RAC_1</dc:creator>
    <dc:date>2004-07-02T10:28:22Z</dc:date>
    <item>
      <title>trim wtmp file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321779#M187508</link>
      <description>I'd like to write a script to trim the wtmp file to only the data for the last three months.  &lt;BR /&gt;&lt;BR /&gt;So I first plan to execute "/usr/sbin/acct/fwtmp &amp;lt; /var/adm/wtmp"&lt;BR /&gt;to get an ascii version of the file.  But the problem I have is that I don't see any easy way to use awk to extract the month and year since the number of fields in the output file can be different.  &lt;BR /&gt;&lt;BR /&gt;For example, my output can be:&lt;BR /&gt;&lt;BR /&gt;xxx2923  ta   pts/ta       10765  8 0000 0000 1018961181 Apr 16 07:46:21 2002&lt;BR /&gt;xxx2923  ts/2 pts/2        17737  7 0000 0000 1018974794 Apr 16 11:33:14 2002 10.0.42.171 10.0.42.171&lt;BR /&gt;         ts/1 pts/1         8025  8 0000 0000 1018992157 Apr 16 16:22:37 2002&lt;BR /&gt;         ts/0 pts/0         7717  8 0000 0000 1018992248 Apr 16 16:24:08 2002&lt;BR /&gt;         ts/2 pts/2        17737  8 0000 0000 1018992250 Apr 16 16:24:10 2002&lt;BR /&gt;root          remshd       19308  7 0000 0000 1019039404 Apr 17 05:30:04 2002 10.0.48.192 pvdv1d09&lt;BR /&gt;&lt;BR /&gt;(note: lines 3,4,5 are blank in the first field)&lt;BR /&gt;&lt;BR /&gt;I can't just use awk to print field $9 to get the month, since field 9 changes depending on the data.&lt;BR /&gt;&lt;BR /&gt;The month and year are always in the same column positions; is there some way to extract a field based on its position in the record (awk or something else)?&lt;BR /&gt;&lt;BR /&gt;TIA,&lt;BR /&gt;Scott</description>
      <pubDate>Fri, 02 Jul 2004 10:10:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321779#M187508</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2004-07-02T10:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: trim wtmp file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321780#M187509</link>
      <description>Why not just use egrep??&lt;BR /&gt;&lt;BR /&gt;cat wtmp_ascii_file|egrep "Apr|May|Jun"&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Fri, 02 Jul 2004 10:13:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321780#M187509</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2004-07-02T10:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: trim wtmp file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321781#M187510</link>
      <description>I want the script to run every month or so, calculating what 'three months ago' is (using caljd.sh), and then proceed to read the old file/write the new file until it reaches 'three months ago'. So I don't think grepping for a specific set of months would work.&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Fri, 02 Jul 2004 10:16:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321781#M187510</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2004-07-02T10:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: trim wtmp file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321782#M187511</link>
      <description>Sorry - reverse that.  It would skip the data until 'three months ago', then start writing the data to the new file.&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Fri, 02 Jul 2004 10:17:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321782#M187511</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2004-07-02T10:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: trim wtmp file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321783#M187512</link>
      <description>echo "1=Jan\n2=Feb\n...12=Dec\n" &amp;gt; /tmp/temp.txt&lt;BR /&gt;&lt;BR /&gt;When you want to excecute it do&lt;BR /&gt;Current_month=`date "+%b"`&lt;BR /&gt;count=`grep "$Current_month" /tmp/temp.txt"|awk -F = '{print $1}'`&lt;BR /&gt;count3=`grep $(($count-3)) /tmp/temp.txt|awk -F = '{print $1}'`&lt;BR /&gt;count2=`grep $(($count-2)) /tmp/temp.txt|awk -F = '{print $1}'`&lt;BR /&gt;count1=`grep $(($count-1)) /tmp/temp.txt|awk -F = '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;fwtmp &amp;lt; /var/adm/wtmp &amp;gt; /tmp/wtmp.txt&lt;BR /&gt;egrep "$count3|$count2|$count1" /tmp/wtmp.txt |fwtmp -ic &amp;gt; /var/adm/wtmp&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Fri, 02 Jul 2004 10:28:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321783#M187512</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2004-07-02T10:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: trim wtmp file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321784#M187513</link>
      <description>Using cut was suggested, so now I have:&lt;BR /&gt;&lt;BR /&gt;/usr/sbin/acct/fwtmp &amp;lt; /var/adm/wtmp | \&lt;BR /&gt; while read RECORD ; do&lt;BR /&gt;_month=`print "$RECORD" | cut -c58-60`&lt;BR /&gt;_year=`print "$RECORD" | cut -c74-77`&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;but this only works when the first field is not blank.. Any ideas?</description>
      <pubDate>Fri, 02 Jul 2004 10:53:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-wtmp-file-by-date/m-p/3321784#M187513</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2004-07-02T10:53:50Z</dc:date>
    </item>
  </channel>
</rss>

