<?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 schedule cron in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980318#M294288</link>
    <description>I want to schedule a cron job to remove files/Directories older than two days under a particular directory(/tmp/PSFTP). Please help me with this.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Jim</description>
    <pubDate>Thu, 12 Apr 2007 13:32:12 GMT</pubDate>
    <dc:creator>Jim92900</dc:creator>
    <dc:date>2007-04-12T13:32:12Z</dc:date>
    <item>
      <title>schedule cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980318#M294288</link>
      <description>I want to schedule a cron job to remove files/Directories older than two days under a particular directory(/tmp/PSFTP). Please help me with this.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Jim</description>
      <pubDate>Thu, 12 Apr 2007 13:32:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980318#M294288</guid>
      <dc:creator>Jim92900</dc:creator>
      <dc:date>2007-04-12T13:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: schedule cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980319#M294289</link>
      <description>01 01 * * 01 /usr/bin/find /tmp/PSFTP -type f -mtime +10 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 12 Apr 2007 13:34:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980319#M294289</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2007-04-12T13:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: schedule cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980320#M294290</link>
      <description>Sorry, correction:&lt;BR /&gt;&lt;BR /&gt;01 01 * * 01 /usr/bin/find /tmp/PSFTP -type f -mtime +2 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 12 Apr 2007 13:35:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980320#M294290</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2007-04-12T13:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: schedule cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980321#M294291</link>
      <description>You would use find to do the actual removal.  Something like:&lt;BR /&gt;&lt;BR /&gt;For files:&lt;BR /&gt;find /starting-dir -type f -mtime +2 -exec rm -f {}+&lt;BR /&gt;&lt;BR /&gt;For dirs:&lt;BR /&gt;find /starting-dir -type d -mtime +2 -exec rm -f {}+&lt;BR /&gt;&lt;BR /&gt;You can then either put those 2 commands in a script and then schedule that via cron, or you can just use those 2 lines as a command in cron and schedule them separately.&lt;BR /&gt;&lt;BR /&gt;To learn how to schedule in cron I suggest perusing the crontab man page (man crontab).&lt;BR /&gt;&lt;BR /&gt;Regarding the above finds, I would also advise doing a 'exec ll -d {}+' prior so you know how find will behave before you actually do the removal.&lt;BR /&gt;&lt;BR /&gt;Once the file is deleted, you have no recourse for getting it back other than restoring from backup.</description>
      <pubDate>Thu, 12 Apr 2007 13:38:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980321#M294291</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2007-04-12T13:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: schedule cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980322#M294292</link>
      <description>Hi Jim:&lt;BR /&gt;&lt;BR /&gt;I agree with Patrick insofar as you said "files" and "directories", but for directory removal you should use 'rmdir':&lt;BR /&gt;&lt;BR /&gt;# find /starting-dir -type d -mtime +2 -exec rmdir {} \+&lt;BR /&gt;&lt;BR /&gt;Note that the "+" character terminates the '-exec command' and like the use of the semicolon in Pete's post *must* be escaped for the shell.&lt;BR /&gt;&lt;BR /&gt;The "+" terminator is available in 11.11 and later and is faster than the semicolon (";") terminator because it bundles multiple arguments together and passes the bundle to the command to run rather than spawning one command for each argument.  The same goal can be met by piping to 'xargs'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;# &lt;BR /&gt;</description>
      <pubDate>Thu, 12 Apr 2007 13:58:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980322#M294292</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-12T13:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: schedule cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980323#M294293</link>
      <description>&amp;gt;JRF: But for directory removal you should use 'rmdir':&lt;BR /&gt;&lt;BR /&gt;If you use rmdir, you need to be prepared for non-empty directory errors.&lt;BR /&gt;&lt;BR /&gt;I suppose removing the files, will touch the directory, so they will be empty first.  But you could use:&lt;BR /&gt;# find /starting-dir -type d -mtime +2 -exec rmdir {} + 2&amp;gt; /dev/null&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Note that the "+" character terminates the '-exec command' and like the use of the semicolon in Pete's post *must* be escaped for the shell.&lt;BR /&gt;&lt;BR /&gt;I asked before, what shell requires "+" to be escaped??  Neither sh nor ksh require it.</description>
      <pubDate>Thu, 12 Apr 2007 22:33:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980323#M294293</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-04-12T22:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: schedule cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980324#M294294</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Dennis &amp;gt; JRF: But for directory removal you should use 'rmdir': If you use rmdir, you need to be prepared for non-empty directory errors.&lt;BR /&gt;&lt;BR /&gt;Exactly.  Depending upon the user's objectives, one may want to remove *files* older than n-days; remove empty directories, too; and leave non-empty ones.  The statement of requirements needs to be clearer.&lt;BR /&gt;&lt;BR /&gt;As for my comments regarding escaping the "+" terminator, I base them on the 'find(1)' manpages (either for 11.11, 11.23 or 11.31) that note under the discussion of '-exec cmd':&lt;BR /&gt;&lt;BR /&gt;/* begin quote */&lt;BR /&gt;&lt;BR /&gt;The end of cmd must be punctuated by a semicolon (;) or a plus sign (+) (semicolon and plus are special to the shell and must be escaped). &lt;BR /&gt;&lt;BR /&gt;/* end quote */&lt;BR /&gt;&lt;BR /&gt;I agree, however, that the absence of the escape character, in practice, doesn't seem to matter.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Apr 2007 07:25:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/schedule-cron/m-p/3980324#M294294</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-16T07:25:36Z</dc:date>
    </item>
  </channel>
</rss>

