<?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: Really ugly file deletion problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902299#M105136</link>
    <description>I've got a one (twelve) line solution which gets rid of a months worth, I guess you could put a few crontab entries which would keep it down to 60 - 90 files.  I don't know if you can afford to do this or not.&lt;BR /&gt;&lt;BR /&gt;I know it's not very clever:&lt;BR /&gt;&lt;BR /&gt;/usr/bin/rm `ls /u01/log/ | grep July` to be run for the cron month 10 (October?) of the year.&lt;BR /&gt;&lt;BR /&gt;This assumes that there are no other files with July in /u01/log that you want to keep. &lt;BR /&gt;&lt;BR /&gt;I guess if I had time I would script it a bit better.&lt;BR /&gt;&lt;BR /&gt;PS: Check what I have written, I'm not ultra confident about it.  All I do know is that it cuts out alot of scripting.</description>
    <pubDate>Wed, 12 Feb 2003 11:43:40 GMT</pubDate>
    <dc:creator>Gavin Clarke</dc:creator>
    <dc:date>2003-02-12T11:43:40Z</dc:date>
    <item>
      <title>Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902293#M105130</link>
      <description>Hello experts,&lt;BR /&gt;&lt;BR /&gt;Please help because I am totally lost. Our document management system creates huge log files that need to be deleted when they exceed 60 days. Now here's the catch. The last access or modification times mean nothing so that I can't do a find -mtime. The only thing that matters is the date string embedded in the filename. It always takes the form "03March2002" or "13September2001" but it is in the middle of the filename. Here's a smalll sample.&lt;BR /&gt;&lt;BR /&gt;/u01/log1/h02071212July2002170041.Log.Z&lt;BR /&gt;/u01/log1/h02071313July2002170033.LOG&lt;BR /&gt;/u01/log1/h02071515July2002170017.Log.Z&lt;BR /&gt;/u01/log1/h02071818July2002170105.LOG&lt;BR /&gt;/u02/log16/B02081919August2003170041.Log.Z&lt;BR /&gt;/u01/log1/h02082020August2003170033.LOG&lt;BR /&gt;/u01/log1/X02082222August2003170017.Log.Z&lt;BR /&gt;&lt;BR /&gt;I can't figure any way to make this work. I've attached a larger list of files. Anybody willing to help me fight this bear?&lt;BR /&gt;&lt;BR /&gt;Thanks for any and all help,&lt;BR /&gt;Bob&lt;BR /&gt;&lt;BR /&gt;P.S. I promise I'll awards points for this. I wish I could award negative points for the designer of this mess.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Feb 2003 01:50:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902293#M105130</guid>
      <dc:creator>Robert Fisher_1</dc:creator>
      <dc:date>2003-02-12T01:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902294#M105131</link>
      <description>Hi Bob:&lt;BR /&gt;&lt;BR /&gt;You're right; this is ugly. A few days ago there was a similar (though simpler problem). Please see my awk solution.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x9e2631ec5e34d711abdc0090277a778c,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x9e2631ec5e34d711abdc0090277a778c,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Yours is more difficult because the regular expressions for the match are more tricky. I also note that a few of the filenames in your data file indicate dates later than the current date? Are these okay?&lt;BR /&gt;&lt;BR /&gt;Good luck (and you are going to need it), Clay&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Feb 2003 01:58:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902294#M105131</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-02-12T01:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902295#M105132</link>
      <description>Thanks Clay for your quick response. You're right about the dates that are newer than today. I'll need to look into that. It looks like I'll need to wait until we figure out what to do with those files as well.&lt;BR /&gt;&lt;BR /&gt;Bob</description>
      <pubDate>Wed, 12 Feb 2003 02:06:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902295#M105132</guid>
      <dc:creator>Robert Fisher_1</dc:creator>
      <dc:date>2003-02-12T02:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902296#M105133</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I can give you half solution using which you can find out the date.  Then use Clay's perl script to determine the difference and delete the ones that are a month's old.&lt;BR /&gt;&lt;BR /&gt;Create a file called months in the current directory and add the entries January February etc., as seperate lines.&lt;BR /&gt;&lt;BR /&gt;$DIR=/u01&lt;BR /&gt;for i in $(ls $DIR)&lt;BR /&gt;do&lt;BR /&gt;FILE=$(echo $i|awk '{FS=".";print $1}')&lt;BR /&gt;&lt;BR /&gt;while read month&lt;BR /&gt;do&lt;BR /&gt;echo $FILE |grep $month &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;MONTH=$month&lt;BR /&gt;break&lt;BR /&gt;fi&lt;BR /&gt;done &amp;lt; months&lt;BR /&gt;&lt;BR /&gt;NEWFILE=$(echo $FILE|sed 's/'$MONTH'//g')&lt;BR /&gt;LEN=$(echo $NEWFILE|wc -c)&lt;BR /&gt;(( A = $LEN - 10 ))&lt;BR /&gt;(( B = $LEN - 7 ))&lt;BR /&gt;YEAR=$(echo $NEWFILE|cut -c ${A}-${B})&lt;BR /&gt;(( A = $LEN - 12 ))&lt;BR /&gt;(( B = $LEN - 11 ))&lt;BR /&gt;DAY=$(echo $NEWFILE|cut -c ${A}-${B})&lt;BR /&gt;&lt;BR /&gt;#You can use DAY,MONTH and YEAR variables now to be used with Clay's caljd script&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;echo $DAY $MONTH $YEAR                            &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 12 Feb 2003 02:34:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902296#M105133</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-02-12T02:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902297#M105134</link>
      <description>Hi Bob,&lt;BR /&gt;&lt;BR /&gt;Here's a bit of perl that does the job.  I've put the list of files in /tmp/files.&lt;BR /&gt;&lt;BR /&gt;It looks for the month string, then the day and year either side, calculates the difference from now, and prints the filename if it's old enough:&lt;BR /&gt;&lt;BR /&gt;============================&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;use Time::Local;&lt;BR /&gt;&lt;BR /&gt;%months=qw(Jan 0 Feb 1 Mar 2 Apr 3 May 4 Jun 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11);&lt;BR /&gt;$now=time;&lt;BR /&gt;$SECS_PER_DAY=60*60*24;&lt;BR /&gt;$diff=60*$SECS_PER_DAY; # how far back&lt;BR /&gt;&lt;BR /&gt;open FH,"/tmp/files"; # list of files&lt;BR /&gt;@files=&lt;FH&gt;;&lt;BR /&gt;close FH;&lt;BR /&gt;&lt;BR /&gt;foreach $file (@files){&lt;BR /&gt; foreach $month (keys %months){&lt;BR /&gt;  if ($file=~/(..)($month)\D*(....)/){&lt;BR /&gt;   $d=$1;&lt;BR /&gt;   $m=$2;&lt;BR /&gt;   $y=$3;&lt;BR /&gt;   $time=timelocal(0,0,0,$d,$months{$m},$y-1900);&lt;BR /&gt;   print "$file" if ( ($now - $time) &amp;gt; $diff );&lt;BR /&gt;   last;&lt;BR /&gt;  }&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;============================&lt;BR /&gt;&lt;BR /&gt;rgds, Robin&lt;/FH&gt;</description>
      <pubDate>Wed, 12 Feb 2003 09:18:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902297#M105134</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-02-12T09:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902298#M105135</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;another solution:&lt;BR /&gt;&lt;BR /&gt;for dat in `ls | grep -i log`&lt;BR /&gt;do&lt;BR /&gt;  actdat=`ls $dat| awk -F . '{printf("%s.%s.%s\n"),substr($1,8,2),substr($1,10,length($1)-19),substr($1,length($1)-9,4) }`&lt;BR /&gt;  if [ "`./diffday $actdat`" -gt 60 ]&lt;BR /&gt;  then&lt;BR /&gt;    ls $dat&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;diffday is a little c-programm:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;int&lt;BR /&gt;main (int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;time_t  t1;&lt;BR /&gt;char *error=0;&lt;BR /&gt;struct tm  endtime;&lt;BR /&gt;int diffday;&lt;BR /&gt; &lt;BR /&gt;/* wrong numbers of arguments */&lt;BR /&gt;if (argc!=2) printf("\nusage: diffday DD.MONTH.YYYY\n");&lt;BR /&gt; &lt;BR /&gt;time (&amp;amp;t1); /* aktual date in seconds */&lt;BR /&gt;endtime = *localtime (&amp;amp;t1); /* seconds to  struct tm */&lt;BR /&gt; &lt;BR /&gt;/* correct format ??? */&lt;BR /&gt;error=strptime(argv[1], "%d.%h.%Y", &amp;amp;endtime);&lt;BR /&gt;if (error==NULL) {&lt;BR /&gt;   printf("wrong format of argument (DD.MONTH.YYYY)\n");&lt;BR /&gt;   exit (1);&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;/* this is the difference */&lt;BR /&gt;t1=mktime (&amp;amp;endtime);&lt;BR /&gt;/* output */&lt;BR /&gt;printf( "%d\n", (int) difftime(time(NULL), t1)/86400);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I have attached the compiled binary for difftime&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris&lt;/TIME.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 12 Feb 2003 10:10:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902298#M105135</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2003-02-12T10:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902299#M105136</link>
      <description>I've got a one (twelve) line solution which gets rid of a months worth, I guess you could put a few crontab entries which would keep it down to 60 - 90 files.  I don't know if you can afford to do this or not.&lt;BR /&gt;&lt;BR /&gt;I know it's not very clever:&lt;BR /&gt;&lt;BR /&gt;/usr/bin/rm `ls /u01/log/ | grep July` to be run for the cron month 10 (October?) of the year.&lt;BR /&gt;&lt;BR /&gt;This assumes that there are no other files with July in /u01/log that you want to keep. &lt;BR /&gt;&lt;BR /&gt;I guess if I had time I would script it a bit better.&lt;BR /&gt;&lt;BR /&gt;PS: Check what I have written, I'm not ultra confident about it.  All I do know is that it cuts out alot of scripting.</description>
      <pubDate>Wed, 12 Feb 2003 11:43:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902299#M105136</guid>
      <dc:creator>Gavin Clarke</dc:creator>
      <dc:date>2003-02-12T11:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902300#M105137</link>
      <description>Ah, have just looked at the attachment, they're not all in the same log file.&lt;BR /&gt;&lt;BR /&gt;Yuk.&lt;BR /&gt;&lt;BR /&gt;I guess it's more like&lt;BR /&gt;&lt;BR /&gt;rm `find /u01 | grep log | grep July`&lt;BR /&gt;Then.&lt;BR /&gt;&lt;BR /&gt;DEFINITELY check this with:&lt;BR /&gt;&lt;BR /&gt;find /u01 | grep log | grep July&lt;BR /&gt;&lt;BR /&gt;Besides it's still not the best solution, it's just the best I can manage in the time I've got.</description>
      <pubDate>Wed, 12 Feb 2003 11:49:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902300#M105137</guid>
      <dc:creator>Gavin Clarke</dc:creator>
      <dc:date>2003-02-12T11:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902301#M105138</link>
      <description>Hi Robert,&lt;BR /&gt;&lt;BR /&gt;attached another Perl version very similar to Robin's.&lt;BR /&gt;The only difference is that it avoids a couple of foreach loops by preparing a regex to match in advance.&lt;BR /&gt;Where it says "print unlink" it actually has to be a real unlink in order to get rid of the file.&lt;BR /&gt;I apologize for not using your attached filelist like robin.&lt;BR /&gt;Instead I tested it with only the little stuff listed beyond the __DATA__ token.&lt;BR /&gt;Today the critical split should occur on 14 Dec 2002 which is 60 days prior to today.&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Wed, 12 Feb 2003 12:00:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902301#M105138</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2003-02-12T12:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902302#M105139</link>
      <description>For reference and FUN  ( based on sed on sort)&lt;BR /&gt;&lt;BR /&gt;sed -e ' s/July/ Jul /                                                                                                              &lt;BR /&gt;s/August/ Aug /' p1 | sort   +2.0 -2.4 -n   +1.0 -1.3 -M  | sed -e 's/ Jul /July/                                                   &lt;BR /&gt;s/ Aug /August/'                                                                                                                    &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Feb 2003 13:52:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902302#M105139</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2003-02-12T13:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902303#M105140</link>
      <description>Okay Bob,&lt;BR /&gt;&lt;BR /&gt;Here's my cut at this:&lt;BR /&gt;&lt;BR /&gt;I do a 'heredocs' to create an awk script to do the actual removes. The system(rm xxx) is commented out so remove the comment when you feel brave. The month names are extracted used the locale LC_TIME command so this should even work with non-English month names.&lt;BR /&gt;&lt;BR /&gt;The script does assume that caljd.sh is in your path.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Feb 2003 20:06:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902303#M105140</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-02-12T20:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902304#M105141</link>
      <description>To keep you from loading an earlier version, use this version of caljd.sh (2.1).&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Feb 2003 20:07:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902304#M105141</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-02-12T20:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902305#M105142</link>
      <description>Thanks everybody. I actually used A. Clay's awk solution only because I am more comfortable with awk than Perl. My next task is to rename all the files after 09February2003 by appending ".BAD" to the filename. An operator set the application date to 02/09/2004 this weekend. &lt;BR /&gt;&lt;BR /&gt;Thanks to all who responded,&lt;BR /&gt;Bob&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Feb 2003 20:43:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902305#M105142</guid>
      <dc:creator>Robert Fisher_1</dc:creator>
      <dc:date>2003-02-12T20:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Really ugly file deletion problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902306#M105143</link>
      <description>Okay Bob,&lt;BR /&gt;&lt;BR /&gt;That was a 2 minute change. Again, test and remove the comment before the system(mv xxx yyy) command. It too expects to read stdin.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Feb 2003 20:52:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/really-ugly-file-deletion-problem/m-p/2902306#M105143</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-02-12T20:52:19Z</dc:date>
    </item>
  </channel>
</rss>

