<?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: reduce log size. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314144#M186166</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;If the log is in use while you're purging it, this can be trouble.&lt;BR /&gt;&lt;BR /&gt;- If you create a new file with your n lines and move it, the file descriptor of the application wihc create the log will be pointing at the wrong file, it will still be able to write - as the unlink remove only the reference to the file - but what will become of the line written ?&lt;BR /&gt;&lt;BR /&gt;- if you work on the same file, issuing a cat /dev/null &amp;gt; log ; cat n_lines_log &amp;gt; log ; you'll get a sparse file.&lt;BR /&gt;&lt;BR /&gt;My 2 cents&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Nicolas</description>
    <pubDate>Thu, 24 Jun 2004 10:15:24 GMT</pubDate>
    <dc:creator>Nicolas Dumeige</dc:creator>
    <dc:date>2004-06-24T10:15:24Z</dc:date>
    <item>
      <title>reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314134#M186156</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I have a large file log 150 MB of text and I like to remove all history except for the last 30 dayâ  s&lt;BR /&gt;The number 149 indicates that a new day is started.&lt;BR /&gt;&lt;BR /&gt;How can I do this quick? &lt;BR /&gt;&lt;BR /&gt;MANY THANKS&lt;BR /&gt;&lt;BR /&gt;Mi</description>
      <pubDate>Thu, 24 Jun 2004 05:28:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314134#M186156</guid>
      <dc:creator>mick001</dc:creator>
      <dc:date>2004-06-24T05:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314135#M186157</link>
      <description>You could try something like:&lt;BR /&gt;&lt;BR /&gt;tail -1000 log &amp;gt; newlog&lt;BR /&gt;&lt;BR /&gt;cat /dev/null &amp;gt;log&lt;BR /&gt;&lt;BR /&gt;cat newlog &amp;gt; log&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Change the 1000 to where ever you want to start from..... &lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Thu, 24 Jun 2004 05:37:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314135#M186157</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-06-24T05:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314136#M186158</link>
      <description>Mi,&lt;BR /&gt;I think the simplest and the best way to do this is by searching for that file for a time stamp and output the result to another file.&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Mobeen</description>
      <pubDate>Thu, 24 Jun 2004 05:38:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314136#M186158</guid>
      <dc:creator>Mobeen_1</dc:creator>
      <dc:date>2004-06-24T05:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314137#M186159</link>
      <description>Find out the line postion from where you want to Keep and use the following &lt;BR /&gt;&lt;BR /&gt;tail -line_number logfile &amp;gt;&amp;gt; logfile.new&lt;BR /&gt;mv logfile.new logfile&lt;BR /&gt;&lt;BR /&gt;sks</description>
      <pubDate>Thu, 24 Jun 2004 05:38:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314137#M186159</guid>
      <dc:creator>Sanjay Kumar Suri</dc:creator>
      <dc:date>2004-06-24T05:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314138#M186160</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;If I use tail -1000 log &amp;gt;log.new&lt;BR /&gt;wc -l log.new I only get 137 lines.&lt;BR /&gt;&lt;BR /&gt;The log file have to start with 149...&lt;BR /&gt;&lt;BR /&gt;THANKS&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jun 2004 05:41:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314138#M186160</guid>
      <dc:creator>mick001</dc:creator>
      <dc:date>2004-06-24T05:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314139#M186161</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can do something like :&lt;BR /&gt;&lt;BR /&gt;grep -n 149 file | tail -16 &lt;BR /&gt;&lt;BR /&gt;Do a wc -l on the output to make sure that there are more than 15 days data by&lt;BR /&gt;if wc -l &amp;gt; 15 &lt;BR /&gt;&lt;BR /&gt;then do a head -n 1 to get the beginning of the record of 15th day subtract 1 from it.&lt;BR /&gt;&lt;BR /&gt;To get the no. of lines to be deleted do&lt;BR /&gt;&lt;BR /&gt; cut -f1 -d":"&lt;BR /&gt;&lt;BR /&gt;do wc -l on the whole file - the no. of lines to be deleted, do a til of these many lines and store it in a file.&lt;BR /&gt;&lt;BR /&gt;I know i have made it  a bit confusing but this is the best I could do as I cannot write a script right now.&lt;BR /&gt;&lt;BR /&gt;manish.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jun 2004 05:44:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314139#M186161</guid>
      <dc:creator>Manish Srivastava</dc:creator>
      <dc:date>2004-06-24T05:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314140#M186162</link>
      <description>Something like this: -&lt;BR /&gt;&lt;BR /&gt;LINE=`grep -n "^149" logfile| tail -30 | head -1 | cut -d: -f1`&lt;BR /&gt;&lt;BR /&gt;This will set the var $LINE to be the line number of the n-30'th day's start.&lt;BR /&gt;&lt;BR /&gt;Then do: -&lt;BR /&gt;&lt;BR /&gt;awk 'NR&amp;gt;'$LINE'' logfile &amp;gt; newlogfile&lt;BR /&gt;mv newlogfile logfile&lt;BR /&gt;&lt;BR /&gt;If you want to do it inline, you could probably use an "ed" script to edit the file, once you have the line numbe from the first command.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sy</description>
      <pubDate>Thu, 24 Jun 2004 05:45:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314140#M186162</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-06-24T05:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314141#M186163</link>
      <description>$ cat file&lt;BR /&gt;hello&lt;BR /&gt;world&lt;BR /&gt;149&lt;BR /&gt;foo&lt;BR /&gt;bar&lt;BR /&gt;149&lt;BR /&gt;what&lt;BR /&gt;else&lt;BR /&gt;can&lt;BR /&gt;I&lt;BR /&gt;put&lt;BR /&gt;here&lt;BR /&gt;149&lt;BR /&gt;?&lt;BR /&gt;&lt;BR /&gt;$ cat run&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;$Index=0;&lt;BR /&gt;$MaxDays=2;&lt;BR /&gt;$Separator="149";&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;  chomp;&lt;BR /&gt;  $CurrentLine=$_;&lt;BR /&gt;  if ($CurrentLine eq $Separator) {&lt;BR /&gt;    $Index=($Index+1)%$MaxDays;&lt;BR /&gt;    $MyTab[$Index]="";&lt;BR /&gt;  } else {&lt;BR /&gt;    $MyTab[$Index].=$CurrentLine."\n";&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;for ($Count=($Index+1)%$MaxDays;$Count&amp;lt;=$Index;$Count++) {&lt;BR /&gt;  print $MyTab[$Count];&lt;BR /&gt;  if ($Count&amp;lt;$Index) { print $Separator."\n"; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$ ./run &amp;lt; file&lt;BR /&gt;what&lt;BR /&gt;else&lt;BR /&gt;can&lt;BR /&gt;I&lt;BR /&gt;put&lt;BR /&gt;here&lt;BR /&gt;149&lt;BR /&gt;?&lt;BR /&gt;&lt;BR /&gt;There is surely better, but it works.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;&lt;/STDIN&gt;</description>
      <pubDate>Thu, 24 Jun 2004 05:59:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314141#M186163</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-06-24T05:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314142#M186164</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I try the commands from Manish Srivastava.&lt;BR /&gt;But then is stil have one problem. &lt;BR /&gt;The command AWK remove the fist 149 line!&lt;BR /&gt;This must be the first line other wise it dousn't work.&lt;BR /&gt;&lt;BR /&gt;THANKS</description>
      <pubDate>Thu, 24 Jun 2004 07:00:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314142#M186164</guid>
      <dc:creator>mick001</dc:creator>
      <dc:date>2004-06-24T07:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314143#M186165</link>
      <description>If you do it with the awk as per my answer, then you can easily change this.&lt;BR /&gt;&lt;BR /&gt;eg it says 'NF&amp;gt;'$LINES'', but it could also say 'NF&amp;gt;'$LINES'-1' etc, to tune to your exact requirements.</description>
      <pubDate>Thu, 24 Jun 2004 07:48:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314143#M186165</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-06-24T07:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314144#M186166</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;If the log is in use while you're purging it, this can be trouble.&lt;BR /&gt;&lt;BR /&gt;- If you create a new file with your n lines and move it, the file descriptor of the application wihc create the log will be pointing at the wrong file, it will still be able to write - as the unlink remove only the reference to the file - but what will become of the line written ?&lt;BR /&gt;&lt;BR /&gt;- if you work on the same file, issuing a cat /dev/null &amp;gt; log ; cat n_lines_log &amp;gt; log ; you'll get a sparse file.&lt;BR /&gt;&lt;BR /&gt;My 2 cents&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Nicolas</description>
      <pubDate>Thu, 24 Jun 2004 10:15:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314144#M186166</guid>
      <dc:creator>Nicolas Dumeige</dc:creator>
      <dc:date>2004-06-24T10:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314145#M186167</link>
      <description>Have you pick the editor option ?&lt;BR /&gt;Opening a 150 Mo file can be too much if you don't have enought resources.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jun 2004 10:17:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314145#M186167</guid>
      <dc:creator>Nicolas Dumeige</dc:creator>
      <dc:date>2004-06-24T10:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: reduce log size.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314146#M186168</link>
      <description>Won't be very fast as well !</description>
      <pubDate>Thu, 24 Jun 2004 10:21:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reduce-log-size/m-p/3314146#M186168</guid>
      <dc:creator>Nicolas Dumeige</dc:creator>
      <dc:date>2004-06-24T10:21:40Z</dc:date>
    </item>
  </channel>
</rss>

