<?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: problem with script to delete old files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119770#M150565</link>
    <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;Sorry I didn't see that you didn't want to walk the tree with this.&lt;BR /&gt;One thought that crosses my mind is to build a file with the find output &amp;amp; then grep -v the file to remove any entry with a "/" in it &amp;amp; use that file to input to an rm command.&lt;BR /&gt;Something like:&lt;BR /&gt;&lt;BR /&gt;find /dir_name -mtime +30 -exec ls {} &amp;gt;&amp;gt; /tmp/rm_files \;&lt;BR /&gt;grep -v "/" /tmp/rm_files &amp;gt; /tmp/rm_files_rm&lt;BR /&gt;while read X&lt;BR /&gt;do&lt;BR /&gt;rm /tmp/dir_name/$X&lt;BR /&gt;done &amp;lt; /tmp/rm_files_rm&lt;BR /&gt;&lt;BR /&gt;I haven't debugged this but have tried it - seems to work OK, so do it with a rm -i the first time to verify.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Jeff</description>
    <pubDate>Fri, 14 Nov 2003 15:26:59 GMT</pubDate>
    <dc:creator>Jeff Schussele</dc:creator>
    <dc:date>2003-11-14T15:26:59Z</dc:date>
    <item>
      <title>problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119763#M150558</link>
      <description>Not exactly a script, but a line contained in a backup script.&lt;BR /&gt;&lt;BR /&gt;find /usr/tmp -type f -atime +30 | cut -c 10- \               &lt;BR /&gt;       | grep -v -e / -e exp$ -e \' | xargs  -i rm /usr/tmp/{}&lt;BR /&gt;&lt;BR /&gt;If run as is (it's been commented out since this started) it takes out almost everything, lucky for me it didn't get anything anyone really cared about so I didn't have to go to tape!&lt;BR /&gt;&lt;BR /&gt;If I take out the xargs at the end and just send it to a file it contains about half the files which include recent files.&lt;BR /&gt;&lt;BR /&gt;So what it was doing before and not now was, removing any files that have not been accessed in the last 30 day excluding sub-directories.&lt;BR /&gt;I have no idea what changed but suddenly one day this line started removing the whole directory.&lt;BR /&gt;&lt;BR /&gt;What could be wrong or what other way can I accomplish this?</description>
      <pubDate>Fri, 14 Nov 2003 12:52:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119763#M150558</guid>
      <dc:creator>Matthew Couper</dc:creator>
      <dc:date>2003-11-14T12:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119764#M150559</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;If all you want to do is rm files unmodified in the last 30 days in a dir, then all you need is:&lt;BR /&gt;&lt;BR /&gt;find /dir_name -mtime +30 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;You don't need to worry about dirs as rm will not delete them - rmdir is needed.&lt;BR /&gt;&lt;BR /&gt;You could add a -i to the rm command to prompt for verification...&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Jeff</description>
      <pubDate>Fri, 14 Nov 2003 13:24:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119764#M150559</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2003-11-14T13:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119765#M150560</link>
      <description>We do something similar out of cron&lt;BR /&gt;&lt;BR /&gt;This little honey blows out core files older than 7 days&lt;BR /&gt;&lt;BR /&gt;OLDEST=7&lt;BR /&gt;&lt;BR /&gt;find / -type f -name core -mtime +${OLDEST} -print &amp;gt; ${RemoveList} 2&amp;gt;/dev/null&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Fri, 14 Nov 2003 13:28:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119765#M150560</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-11-14T13:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119766#M150561</link>
      <description>Hi,&lt;BR /&gt;If I understand uou correct you want to remove all files in /usr/tmp older then 30 days but not remove files in subdirectorys.&lt;BR /&gt;I found no easy solution but perhaps "dirname" can be used. Something like:&lt;BR /&gt;&lt;BR /&gt;find usr/tmp -type f -atime +30 |while read file&lt;BR /&gt;do&lt;BR /&gt;if [ `dirname $file` = "/usr/tmp" ]&lt;BR /&gt;then&lt;BR /&gt;rm $file&lt;BR /&gt;fi&lt;BR /&gt;done</description>
      <pubDate>Fri, 14 Nov 2003 13:29:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119766#M150561</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2003-11-14T13:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119767#M150562</link>
      <description>regarding why your command now fails, perhaps you could try putting it back in, but moodifying it so it doesn't remove files, but rather creates a listing of the files with their atime that you can look at later. This would be a better test of what it is doing in situ ( within your backup script) as it were, rather than playing with the command after the fact from a terminal session. for example:&lt;BR /&gt;&lt;BR /&gt;...  | xargs -i ls -lu /usr/tmp/{} &amp;gt; mylisting.out&lt;BR /&gt;&lt;BR /&gt;or something like that...&lt;BR /&gt;&lt;BR /&gt; - John&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Nov 2003 13:45:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119767#M150562</guid>
      <dc:creator>John Kittel</dc:creator>
      <dc:date>2003-11-14T13:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119768#M150563</link>
      <description>after re-reading your original question, I see that my suggestion to modify commmand in script to output to a file was something you already tried...  however, if you didn't do that with ls -lu to get the atime in the output, I still think *that* part of my suggestion is worth a try...&lt;BR /&gt;&lt;BR /&gt; - John</description>
      <pubDate>Fri, 14 Nov 2003 14:38:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119768#M150563</guid>
      <dc:creator>John Kittel</dc:creator>
      <dc:date>2003-11-14T14:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119769#M150564</link>
      <description>Did you change something in your backup procedure recently?  Some backup methods will update atime with the time at which they were backed up.</description>
      <pubDate>Fri, 14 Nov 2003 15:10:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119769#M150564</guid>
      <dc:creator>James A. Donovan</dc:creator>
      <dc:date>2003-11-14T15:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119770#M150565</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;Sorry I didn't see that you didn't want to walk the tree with this.&lt;BR /&gt;One thought that crosses my mind is to build a file with the find output &amp;amp; then grep -v the file to remove any entry with a "/" in it &amp;amp; use that file to input to an rm command.&lt;BR /&gt;Something like:&lt;BR /&gt;&lt;BR /&gt;find /dir_name -mtime +30 -exec ls {} &amp;gt;&amp;gt; /tmp/rm_files \;&lt;BR /&gt;grep -v "/" /tmp/rm_files &amp;gt; /tmp/rm_files_rm&lt;BR /&gt;while read X&lt;BR /&gt;do&lt;BR /&gt;rm /tmp/dir_name/$X&lt;BR /&gt;done &amp;lt; /tmp/rm_files_rm&lt;BR /&gt;&lt;BR /&gt;I haven't debugged this but have tried it - seems to work OK, so do it with a rm -i the first time to verify.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Jeff</description>
      <pubDate>Fri, 14 Nov 2003 15:26:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119770#M150565</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2003-11-14T15:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119771#M150566</link>
      <description>Sorry - line 5 should be:&lt;BR /&gt;&lt;BR /&gt;rm /dir_name/$X&lt;BR /&gt;&lt;BR /&gt;Jeff</description>
      <pubDate>Fri, 14 Nov 2003 15:43:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119771#M150566</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2003-11-14T15:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119772#M150567</link>
      <description>Good suggestions, thanks&lt;BR /&gt;but...&lt;BR /&gt;&lt;BR /&gt;When sending the output to a  file and looking at what it captures, it seems to grab too much (files created recently) so I wonder if I need to add a mtime also? I need to preserve files that are still being accessed otherwise they will need to run that report again which might be very inconvient.&lt;BR /&gt;&lt;BR /&gt;I'm looking at the output of this and it might be what I need, don't know why -atime alone doesn't handle it anymore...&lt;BR /&gt;&lt;BR /&gt;find /usr/tmp -type f -atime +30 -mtime +30| cut -c 10- \| grep -v -e / -e exp$ -e \'|xargs -i ll /usr/tmp/{}&lt;BR /&gt;&lt;BR /&gt;I'll swap the ll for an rm and I should see a lot of new space available (hopfully not TOO much! :)</description>
      <pubDate>Fri, 14 Nov 2003 16:58:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119772#M150567</guid>
      <dc:creator>Matthew Couper</dc:creator>
      <dc:date>2003-11-14T16:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119773#M150568</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;atime is access - the find itself will modify atime. mtime is modification or change of the file contents. ctime is inode attribute change - owner, perms, links etc.&lt;BR /&gt;Just *what* are you looking for in these files in the above?&lt;BR /&gt;&lt;BR /&gt;Jeff</description>
      <pubDate>Fri, 14 Nov 2003 17:11:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119773#M150568</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2003-11-14T17:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119774#M150569</link>
      <description>not sure if further clarification needed on this point, but if only for sake of interest in why current command fails, in the latest example of the command that you give, ll will output mtime, which will not necessarily illustrate what's heppening with the original version of your command with just -atime. Use ls -lu to get atime in output.&lt;BR /&gt;&lt;BR /&gt;Also, following up on one of the other suggestions, I've also seen virus check s/w twiddle with atimes. So to reiterate that bit, if you've recently changed backup or virus check ( if any) s/w - those could be a cause of your backup script suddenly failing.&lt;BR /&gt;&lt;BR /&gt; - John</description>
      <pubDate>Fri, 14 Nov 2003 17:13:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119774#M150569</guid>
      <dc:creator>John Kittel</dc:creator>
      <dc:date>2003-11-14T17:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119775#M150570</link>
      <description>Old files that are no longer needed/used&lt;BR /&gt;That last command using the rm did a good job&lt;BR /&gt;Doesn't look like find touchs the atime, you would need to open the file to touch it for the atime. I just ran about 20 finds on that directory today and came with the same results everytime&lt;BR /&gt;I'm not sure why filtering by atime +30 was giving files created 2 days ago (never been accessed so there was no atime to read?), but the addition of mtime +30 filtered out all of those giving me a list of what was mostly scratch files and forgotten user reports, perfect!&lt;BR /&gt;Not sure what was more helpful, all the feedback or me thinking 'outloud', anyway...thanks guys!</description>
      <pubDate>Fri, 14 Nov 2003 17:18:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119775#M150570</guid>
      <dc:creator>Matthew Couper</dc:creator>
      <dc:date>2003-11-14T17:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119776#M150571</link>
      <description>It's entirely possible to have atime older than modification time. For example, create a file right now. for example,&lt;BR /&gt;&lt;BR /&gt;# touch myfile&lt;BR /&gt;# ll myfile&lt;BR /&gt;-rw-r--r--   1 root       sys              0 Nov 14 14:23 myfile&lt;BR /&gt;# ls -lu myfile&lt;BR /&gt;-rw-r--r--   1 root       sys              0 Nov 14 14:23 myfile&lt;BR /&gt;# touch -a -t 10010000 myfile &lt;BR /&gt;# ll myfile&lt;BR /&gt;-rw-r--r--   1 root       sys              0 Nov 14 14:23 myfile&lt;BR /&gt;# ls -lu myfile&lt;BR /&gt;-rw-r--r--   1 root       sys              0 Oct  1 00:00 myfile&lt;BR /&gt;# &lt;BR /&gt;&lt;BR /&gt; - John</description>
      <pubDate>Fri, 14 Nov 2003 17:24:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119776#M150571</guid>
      <dc:creator>John Kittel</dc:creator>
      <dc:date>2003-11-14T17:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119777#M150572</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;try this&lt;BR /&gt;find /usr/tmp -type f -atime +30 -prune -exec rm "{}" ";"&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Sat, 15 Nov 2003 21:31:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119777#M150572</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-15T21:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119778#M150573</link>
      <description>Just a cosmetic note: /usr/tmp has not existed for the last 10 years or so. The directory name is /var/tmp. The reason this works is that /usr/tmp is actually a symbolic link. There is no /bin or /lib directory--same reason. These are called transition links meanung that you will be modifying all your old scripts to use the current V.4 filesystem layout standards. These transition links can be removed with tlremove and may not be the default in future releases of HP-UX.</description>
      <pubDate>Sun, 16 Nov 2003 23:12:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119778#M150573</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2003-11-16T23:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119779#M150574</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;are you still with us? If so, is your problem solved? &lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael.</description>
      <pubDate>Mon, 17 Nov 2003 05:59:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119779#M150574</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-17T05:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: problem with script to delete old files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119780#M150575</link>
      <description>Just to clearify, here's the final line that works for what I'm looking for...&lt;BR /&gt;&lt;BR /&gt;find /usr/tmp -type f -atime +30 -mtime +30 | cut -c 10- | grep -v -e / -e exp$ -e \' | xargs  -i rm /usr/tmp/{}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks again for all the help!</description>
      <pubDate>Wed, 11 Feb 2004 09:54:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-script-to-delete-old-files/m-p/3119780#M150575</guid>
      <dc:creator>Matthew Couper</dc:creator>
      <dc:date>2004-02-11T09:54:03Z</dc:date>
    </item>
  </channel>
</rss>

