<?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: ksh script for removing old files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991427#M124455</link>
    <description>&lt;BR /&gt;More efficient than&lt;BR /&gt;&lt;BR /&gt;find /path -type f -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;is&lt;BR /&gt;&lt;BR /&gt;find /path -type f -exec rm \+&lt;BR /&gt;&lt;BR /&gt;which works just like&lt;BR /&gt;&lt;BR /&gt;find /path -type f | xargs rm&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;As far as I know, this is only true with HP-UX find. For portability, use the find|xargs pipeline when working with long lists.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 06 Jun 2003 20:38:45 GMT</pubDate>
    <dc:creator>Jordan Bean</dc:creator>
    <dc:date>2003-06-06T20:38:45Z</dc:date>
    <item>
      <title>ksh script for removing old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991421#M124449</link>
      <description>I'm trying to create a simple script that would remove files in an archive. Since the naming is close to the same, I'd like to do it by date. Ideally, I'd like to keep 1-2 months of data. That being said, I could do it by grep "Jan" or something like that or I could do it with something utilizing $(( (90-$(date +%j)) )) or something similar. Currently the directory contains files beginning January 1 through today. I'd like to keep May and June. Going forward, when run, it should maintain 2 months of data in the directory. Any help would be appreciated. As you can tell, scripting is not my strong suit...&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Dave</description>
      <pubDate>Fri, 06 Jun 2003 19:39:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991421#M124449</guid>
      <dc:creator>David Bell_1</dc:creator>
      <dc:date>2003-06-06T19:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script for removing old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991422#M124450</link>
      <description>Very simply you can:&lt;BR /&gt;&lt;BR /&gt;find /your/dir -type f -mtime +60 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;Be very carefull with find and "-exec rm" make sure that you use an EXPLICIT file location. NEVER cd to directory and start removing files in a script. That will bite you someday when the directory is moved/renamed etc.&lt;BR /&gt;&lt;BR /&gt;Good luck</description>
      <pubDate>Fri, 06 Jun 2003 19:47:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991422#M124450</guid>
      <dc:creator>John Dvorchak</dc:creator>
      <dc:date>2003-06-06T19:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script for removing old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991423#M124451</link>
      <description>Dave -&lt;BR /&gt;find /tmp/ -type f -mtime -1 &amp;gt; $FILE_LIST_TMP 2&amp;gt;$RESULTS_FILE&lt;BR /&gt; ==&amp;gt; used to build a list of files created in the last 24 hours. Then using this list simply do a for loop on a cat of the file to perform the rm on.&lt;BR /&gt;&lt;BR /&gt;Man find, you will find other time options. In this case -1 is the interval of 24 hour periods.&lt;BR /&gt;&lt;BR /&gt;Best of luck.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;dl</description>
      <pubDate>Fri, 06 Jun 2003 19:50:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991423#M124451</guid>
      <dc:creator>Dave La Mar</dc:creator>
      <dc:date>2003-06-06T19:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script for removing old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991424#M124452</link>
      <description>Well, it could be something as simple as&lt;BR /&gt;&lt;BR /&gt;find dirname -type f -mtime +60 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;substitute something innocuous like "echo" for the rm until you feel safe. This will delete all regular files older than 60 days undir dirname (and it's subdirectories).&lt;BR /&gt;&lt;BR /&gt;The date +%j stuff is not very robust because of end of year issues.&lt;BR /&gt;&lt;BR /&gt;If you must you something that converts Date encoded filenames into meaningful numeric values then I would use caljd.sh. It will easily parse the Monthnames (in any language). Search the forums for caljd.sh and you should get a number of hits. Get version 2.1; it's the latest&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;If you will give a few exact examples of the filenames, I can probably write an example caljd.sh call.&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Jun 2003 19:52:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991424#M124452</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-06-06T19:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script for removing old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991425#M124453</link>
      <description>I have something like:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;# Script to remove old print jobs&lt;BR /&gt;# Geoff Wild&lt;BR /&gt;# April 4 2002&lt;BR /&gt;#&lt;BR /&gt;find /var/spool/lp/receive -name '*III'  -mtime +7 -exec rm {} \; &amp;gt;/tmp/lp.receive.log&lt;BR /&gt;find /var/spool/lp/receive -name '*AAA'  -mtime +7 -exec rm {} \; &amp;gt;&amp;gt;/tmp/lp.receive.log&lt;BR /&gt;find /var/spool/lp/receive -name '*EEE'  -mtime +7 -exec rm {} \; &amp;gt;&amp;gt;/tmp/lp.receive.log&lt;BR /&gt;find /var/adm/lp/XEB -name '*ftplog'  -mtime +7 -exec rm {} \; &amp;gt;&amp;gt;/tmp/lp.receive.log&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RGds...Geoff&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Jun 2003 20:01:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991425#M124453</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2003-06-06T20:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script for removing old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991426#M124454</link>
      <description>Guys,&lt;BR /&gt;&lt;BR /&gt;All good and viable examples. I thank you for the assistance. For the life of me I can't see how but I missed the -exec!!!!&lt;BR /&gt;&lt;BR /&gt;Clay,&lt;BR /&gt;&lt;BR /&gt;Thanks for the info on the caljd.sh. I'll look into it and post if I can't figure out how to utilize it. The information provided is quite sufficient for now.&lt;BR /&gt;&lt;BR /&gt;Thanks again,&lt;BR /&gt;&lt;BR /&gt;Dave</description>
      <pubDate>Fri, 06 Jun 2003 20:10:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991426#M124454</guid>
      <dc:creator>David Bell_1</dc:creator>
      <dc:date>2003-06-06T20:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script for removing old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991427#M124455</link>
      <description>&lt;BR /&gt;More efficient than&lt;BR /&gt;&lt;BR /&gt;find /path -type f -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;is&lt;BR /&gt;&lt;BR /&gt;find /path -type f -exec rm \+&lt;BR /&gt;&lt;BR /&gt;which works just like&lt;BR /&gt;&lt;BR /&gt;find /path -type f | xargs rm&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;As far as I know, this is only true with HP-UX find. For portability, use the find|xargs pipeline when working with long lists.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Jun 2003 20:38:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991427#M124455</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2003-06-06T20:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script for removing old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991428#M124456</link>
      <description>Jordan,&lt;BR /&gt;&lt;BR /&gt;Thanks for the additional information.&lt;BR /&gt;&lt;BR /&gt;Dave</description>
      <pubDate>Mon, 09 Jun 2003 19:13:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-for-removing-old-files/m-p/2991428#M124456</guid>
      <dc:creator>David Bell_1</dc:creator>
      <dc:date>2003-06-09T19:13:51Z</dc:date>
    </item>
  </channel>
</rss>

