<?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: Find Command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773503#M640641</link>
    <description>Thanks James!&lt;BR /&gt;&lt;BR /&gt;I've incorporated the Perl snippet and the ref file has a timestamp exactly two hours old. I've also taken note of the "+" terminator, I did not know this.&lt;BR /&gt;&lt;BR /&gt;Hein,&lt;BR /&gt;&lt;BR /&gt;I did not try your suggested syntax, but will when I get the chance. Thanks for the response.</description>
    <pubDate>Mon, 04 Apr 2011 18:43:55 GMT</pubDate>
    <dc:creator>John Carver</dc:creator>
    <dc:date>2011-04-04T18:43:55Z</dc:date>
    <item>
      <title>Find Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773499#M640637</link>
      <description>I am writting debug logs to the /tmp directory for an application fix. These logs fill up the /tmp directory very quickly and I only need logs for the last 2 hours at any given moment in time. I want to include the find command in a script that continuously runs every 15 minutes and finds files with a specific name older than 2 hours and deletes them. I've been running the example below for awhile. It deletes files older than 1 hour and runs every hour so I have files anywhere between 1 and 2 hours old. Now I need to run every 15 minutes but delete files older than 2 hours. In other words, I need to retain roughly 2 hours of logs at all times.&lt;BR /&gt;&lt;BR /&gt;I can't see if there's a way to do this with find or if I have to resort to something else.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;        find /tmp -name "udapiserver*" ! -newer /tmp/findref -exec rm {} \;&lt;BR /&gt;        touch /tmp/findref&lt;BR /&gt;        sleep 3600&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;exit</description>
      <pubDate>Mon, 04 Apr 2011 17:26:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773499#M640637</guid>
      <dc:creator>John Carver</dc:creator>
      <dc:date>2011-04-04T17:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Find Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773500#M640638</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;One way is to use a small Perl snippet :&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;WHEN=$(perl -MPOSIX -e 'print strftime "%Y%m%d%H%M\n",localtime(time-(2*60*60))')&lt;BR /&gt;touch -amt ${WHEN} /tmp/findref&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Now, your 'findref' file has a modification timestamp two hours ago (2*60*60 seconds ago) and you can awaken an compare to it as you need.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Apr 2011 17:55:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773500#M640638</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-04T17:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Find Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773501#M640639</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Since you are not asking anything tricky from find (and even if you did), you may want to consider to have a shell or perl script do a glob and look at the date attribute to decide whether a file is a keeper or not.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for example:&lt;BR /&gt;&lt;BR /&gt;$ perl -e 'for () { unlink if -M $_ &amp;gt; 2/24 }'&lt;BR /&gt;&lt;BR /&gt;The -M function returns the age of the file as a floating point value with unit days.&lt;BR /&gt;&lt;BR /&gt;So for 2 hours you want to compare using 2/24&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Apr 2011 18:05:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773501#M640639</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2011-04-04T18:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Find Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773502#M640640</link>
      <description>Hi (again) :&lt;BR /&gt;&lt;BR /&gt;By the way, if you want to avoid poor 'find' performance, use the '+' terminator to the '-exec' argument like:&lt;BR /&gt;&lt;BR /&gt;# find /tmp -type f -name "udapiserver*" ! -newer /tmp/findref -exec rm {} +&lt;BR /&gt;&lt;BR /&gt;This causes multiple arguments to be collected for every 'rm' process spawned instead of forking one 'rm' for every file to be removed.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 04 Apr 2011 18:10:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773502#M640640</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-04T18:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773503#M640641</link>
      <description>Thanks James!&lt;BR /&gt;&lt;BR /&gt;I've incorporated the Perl snippet and the ref file has a timestamp exactly two hours old. I've also taken note of the "+" terminator, I did not know this.&lt;BR /&gt;&lt;BR /&gt;Hein,&lt;BR /&gt;&lt;BR /&gt;I did not try your suggested syntax, but will when I get the chance. Thanks for the response.</description>
      <pubDate>Mon, 04 Apr 2011 18:43:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773503#M640641</guid>
      <dc:creator>John Carver</dc:creator>
      <dc:date>2011-04-04T18:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Find Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773504#M640642</link>
      <description>&amp;gt;I only need logs for the last 2 hours at any given moment in time. I want to include the find command in a script that runs every 15 minutes&lt;BR /&gt;&lt;BR /&gt;If you don't want to use the perl solution to create the reference files, you'll need to have a sequence of 8 reference files and use and touch the appropriate one each 15 minutes.</description>
      <pubDate>Mon, 04 Apr 2011 18:47:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773504#M640642</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-04-04T18:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Find Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773505#M640643</link>
      <description>&amp;gt;&amp;gt; I did not try your suggested syntax, but will when I get the chance. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Try a non-destructive version first.&lt;BR /&gt;&lt;BR /&gt;Just after your purge runs, rerun the find, and compare with output from:&lt;BR /&gt;&lt;BR /&gt;perl -e 'for () {$m = -M; print qq($m $_\n) if $m &amp;gt; 2/24 }'&lt;BR /&gt;&lt;BR /&gt;That would just be to get familiar with this method.&lt;BR /&gt;&lt;BR /&gt;for () {...}  # walk list, setting $_, executing code block each time&lt;BR /&gt; # glob list of filenames matching specification&lt;BR /&gt;$m = -M; # store file modification date in varariable $m&lt;BR /&gt;&lt;BR /&gt;print qq($m $_\n) if $m &amp;gt; 2/24  # real work.&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Apr 2011 19:06:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-command/m-p/4773505#M640643</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2011-04-04T19:06:41Z</dc:date>
    </item>
  </channel>
</rss>

