<?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: Continuously archiving directory contents in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669930#M50663</link>
    <description>What about something like this, which would start moving the oldest files to a new location first, always checking whether a process has the file open...&lt;BR /&gt;&lt;BR /&gt;olddir=/abc&lt;BR /&gt;newdir=/xyz&lt;BR /&gt;cd $olddir&lt;BR /&gt;ls -rt | while read f&lt;BR /&gt;do&lt;BR /&gt;  open=`fuser $f 2&amp;gt;/dev/null`&lt;BR /&gt;  if [ "$open" = "" ] ; then&lt;BR /&gt;    mv $f $newdir&lt;BR /&gt;  else&lt;BR /&gt;    echo "file $f is held open by processes ${open}"&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This is untested, so you might want to create some test stuff first before using...&lt;BR /&gt;Also it won't work if there are sub-directories in the directory being archived&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
    <pubDate>Fri, 22 Feb 2002 14:34:01 GMT</pubDate>
    <dc:creator>Duncan Edmonstone</dc:creator>
    <dc:date>2002-02-22T14:34:01Z</dc:date>
    <item>
      <title>Continuously archiving directory contents</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669927#M50660</link>
      <description>Hi,&lt;BR /&gt;I am wondering if there is a clever more efficient method to do what i am doing now. I have directories that are continuously growing with thousands of small files being created at a rate of over 100 every 5 minutes!  Obviously this is a headache to deal with, and results in fbackup taking hours to run as some directories on this machine have over 1 million files in them by now.  Anyway, I was going to tar the directories, delete the directory with rm -r and then recreate it again, but this would mean that files being created would fail for the time between directory deletion and recreation.  Next I was going to run a recursive "for i in `ls -1, etc" in the directory to move the files to a tmp location and then delete them.  The tmp location would then be archived and deleted itself.  The problem with this is that i have to check the size of each file before moving it to prevent partial copies.  Again with the number of files involved, and the number of directories this needs to be done with, the overhead would be too much.  I am sure there is a much more clever way of archiving files to keep the qty down to take the pressure off fbackup. I am also sure that loads of sys admins must have to deal with this and someone has figured out how.  I want to avoid "find" as they are too heavy on the processor, there could be 20 running at once on this box.  Any help would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Dermot.</description>
      <pubDate>Fri, 22 Feb 2002 10:21:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669927#M50660</guid>
      <dc:creator>Dermot Beirne</dc:creator>
      <dc:date>2002-02-22T10:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Continuously archiving directory contents</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669928#M50661</link>
      <description>Hi,&lt;BR /&gt;Wow, that looks like fun :-).&lt;BR /&gt;I use the "for loop" you described. However, on my system I am sure that all but the most recent file are "complete". Using ls -rt1 makes it very easy to exclude this last file.&lt;BR /&gt;&lt;BR /&gt;It may not be the solution you are looking for, but if your situation is simular, it would be a very easy one.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Tom Geudens</description>
      <pubDate>Fri, 22 Feb 2002 11:44:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669928#M50661</guid>
      <dc:creator>Tom Geudens</dc:creator>
      <dc:date>2002-02-22T11:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Continuously archiving directory contents</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669929#M50662</link>
      <description>Take the reverse way :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;1- create several directories:&lt;BR /&gt;&lt;BR /&gt;mkdir 0 1 2 3 4 5 6 7 8 ....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now use symbolic links:&lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;let maxd=9&lt;BR /&gt;let dir=0&lt;BR /&gt;&lt;BR /&gt;while  [ 1 ]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;let dir=$dir%$maxd  &lt;BR /&gt;&lt;BR /&gt;mv YOURDIR YOUROPENDIR&lt;BR /&gt;ln -s $dir YOURDIR&lt;BR /&gt;sleep 600&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;-----&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In this way you will change of dir each 10 minutes. You will find some benefits:&lt;BR /&gt;&lt;BR /&gt;1- open files remains open&lt;BR /&gt;2- shorter directories structures&lt;BR /&gt;3- Now you can test, backup, and remove dir by dir.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;:-))&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Feb 2002 12:47:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669929#M50662</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2002-02-22T12:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Continuously archiving directory contents</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669930#M50663</link>
      <description>What about something like this, which would start moving the oldest files to a new location first, always checking whether a process has the file open...&lt;BR /&gt;&lt;BR /&gt;olddir=/abc&lt;BR /&gt;newdir=/xyz&lt;BR /&gt;cd $olddir&lt;BR /&gt;ls -rt | while read f&lt;BR /&gt;do&lt;BR /&gt;  open=`fuser $f 2&amp;gt;/dev/null`&lt;BR /&gt;  if [ "$open" = "" ] ; then&lt;BR /&gt;    mv $f $newdir&lt;BR /&gt;  else&lt;BR /&gt;    echo "file $f is held open by processes ${open}"&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This is untested, so you might want to create some test stuff first before using...&lt;BR /&gt;Also it won't work if there are sub-directories in the directory being archived&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Fri, 22 Feb 2002 14:34:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669930#M50663</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2002-02-22T14:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Continuously archiving directory contents</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669931#M50664</link>
      <description>Thanks all for your help. The script you have looks good Duncan, and I can modify it to move recursively through subdirectories.  I believe that the reliability of fuser is questionable, but lsof seems to make up for this.  I'll test extensively, and in our environment an errors will be detected *very* quickly :)&lt;BR /&gt;&lt;BR /&gt;Dermot</description>
      <pubDate>Mon, 25 Feb 2002 14:26:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669931#M50664</guid>
      <dc:creator>Dermot Beirne</dc:creator>
      <dc:date>2002-02-25T14:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Continuously archiving directory contents</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669932#M50665</link>
      <description>Thanks for the points Dermot - you just pushed me onto my next hat! Wizard eh? that takes me back to very distant days of MUD!&lt;BR /&gt;&lt;BR /&gt;So where do I get my FOD ;o)&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Feb 2002 18:18:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669932#M50665</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2002-02-25T18:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: Continuously archiving directory contents</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669933#M50666</link>
      <description>I got around a similar problem once by doing some hard-link manipulation:&lt;BR /&gt;&lt;BR /&gt;ln dirname dirname.&lt;DATE&gt;&lt;BR /&gt;mkdir newdirname&lt;BR /&gt;# now force dirname to refer to the new directory...&lt;BR /&gt;ln -f newdirname dirname&lt;BR /&gt;unlink newdirname&lt;BR /&gt;&lt;BR /&gt;This results in the existing directory being moved aside without affecting processes with files already open or processes that wish to create new files, because dirname always exists.  A fresh new directory is now in place and you can do what you like with the old directory.&lt;BR /&gt;&lt;BR /&gt;This may or may not work in your case, depending on your application, but it was quite effective in my case.  I had the script running every 5 minutes which you could tweak depending on the rate at which new files are created.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Steve&lt;BR /&gt;&lt;/DATE&gt;</description>
      <pubDate>Mon, 25 Feb 2002 18:30:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/continuously-archiving-directory-contents/m-p/2669933#M50666</guid>
      <dc:creator>Steven Gillard_2</dc:creator>
      <dc:date>2002-02-25T18:30:57Z</dc:date>
    </item>
  </channel>
</rss>

