<?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 a log file by date in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675697#M52009</link>
    <description>Hi again:&lt;BR /&gt;&lt;BR /&gt;And now the other part, caljd.sh.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 04 Mar 2002 16:51:59 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2002-03-04T16:51:59Z</dc:date>
    <item>
      <title>Trim a log file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675694#M52006</link>
      <description>Okay here goes...&lt;BR /&gt;&lt;BR /&gt;I have scripts that run on a box that need to have log files for the past two months.  However the files do get quite large, and I need to trim them to only include the pat 60 days.  Here is an example of the output of the log file:&lt;BR /&gt;&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  RECESS Not Valid.&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  RECESS Not Valid.&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  RECESS Not Valid.&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  RECESS Not Valid.&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  RECESS Not Valid.&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  RECESS Not Valid.&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  RECESS Not Valid.&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  RECESS Not Valid.&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  Bulding DataLog File test_A87026.1_I9-REC3-C_01&lt;BR /&gt;Mon Feb 11 15:07:34 EST 2002  ./RECZ01EA.tcl:  RECZ01EA A87026.1 I9-REC3-C Finished.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My question is how do I create the script to only remove entires older than 60 days?&lt;BR /&gt;&lt;BR /&gt;There could be any number of entries ranging from none in a day, to 100 in a day, so just tailing the end of the file won't work...&lt;BR /&gt;&lt;BR /&gt;thanks for the help.  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Mar 2002 16:04:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675694#M52006</guid>
      <dc:creator>Norman England</dc:creator>
      <dc:date>2002-03-04T16:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Trim a log file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675695#M52007</link>
      <description>Just curious, would it be better to have a process in place to archive and compress the "full" log file to somewhere else vs deleting the entries in it ? Those archived log files can be deleted on a regular basis after.</description>
      <pubDate>Mon, 04 Mar 2002 16:36:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675695#M52007</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-03-04T16:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trim a log file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675696#M52008</link>
      <description>Hi Norman:&lt;BR /&gt;&lt;BR /&gt;This should be fairly close. The idea is to parse that date format into a numerical month, day, year format and then use that to feed me universal date hammer 'caljd.sh'. It returns the number of days since ~Jan 1, 4713BCE (the Julian Day). If we compare the today's Julian Day to that of your log entry and the age is greater than 60 we simply don't echo the line.&lt;BR /&gt;&lt;BR /&gt;I'll do this in two attachments so that you get both parts:&lt;BR /&gt;&lt;BR /&gt;The general idea is this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;PID=$$&lt;BR /&gt;TF1=${TDIR}/X${PID}_1.txt&lt;BR /&gt;LOGFILE=mylogfile&lt;BR /&gt;&lt;BR /&gt;cat ${LOGFILE} | awk -f trim.awk &amp;gt; ${TF1}&lt;BR /&gt;STAT=$?&lt;BR /&gt;if [ ${STAT} -eq 0 ]&lt;BR /&gt;  then&lt;BR /&gt;    mv ${TF1} ${LOGFILE}&lt;BR /&gt;  else&lt;BR /&gt;    rm -f ${TF1}&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here is the first part, 'trim.awk'. If you like, you could make it a part of the above script with a 'here doc'.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Mar 2002 16:51:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675696#M52008</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-03-04T16:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Trim a log file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675697#M52009</link>
      <description>Hi again:&lt;BR /&gt;&lt;BR /&gt;And now the other part, caljd.sh.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Mar 2002 16:51:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675697#M52009</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-03-04T16:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Trim a log file by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675698#M52010</link>
      <description>Norman, it sounds like it would be easier to have the logs "rotated" once a month, or maybe even "weekly".&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 04 Mar 2002 16:55:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trim-a-log-file-by-date/m-p/2675698#M52010</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-03-04T16:55:40Z</dc:date>
    </item>
  </channel>
</rss>

