<?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 file active during ftp being processed. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180851#M162883</link>
    <description>Hi I made a script to mv some files from /dir1 to /dir2 to freeup diskspace for /dir1 which in increasing because other servers are dumping file to it via ftp.&lt;BR /&gt;My problem is how can I edit my script such that I cannot mv a file from /dir1 to /dir2 while at the same time it is being dumped via ftp from other servers to /dir1. Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;Ferdie</description>
    <pubDate>Mon, 02 Feb 2004 22:46:39 GMT</pubDate>
    <dc:creator>Ferdie Castro</dc:creator>
    <dc:date>2004-02-02T22:46:39Z</dc:date>
    <item>
      <title>file active during ftp being processed.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180851#M162883</link>
      <description>Hi I made a script to mv some files from /dir1 to /dir2 to freeup diskspace for /dir1 which in increasing because other servers are dumping file to it via ftp.&lt;BR /&gt;My problem is how can I edit my script such that I cannot mv a file from /dir1 to /dir2 while at the same time it is being dumped via ftp from other servers to /dir1. Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;Ferdie</description>
      <pubDate>Mon, 02 Feb 2004 22:46:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180851#M162883</guid>
      <dc:creator>Ferdie Castro</dc:creator>
      <dc:date>2004-02-02T22:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: file active during ftp being processed.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180852#M162884</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Use a tmp file as a semaphore, or if your app supports it, use file locking.</description>
      <pubDate>Mon, 02 Feb 2004 23:09:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180852#M162884</guid>
      <dc:creator>Christopher Caldwell</dc:creator>
      <dc:date>2004-02-02T23:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: file active during ftp being processed.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180853#M162885</link>
      <description>filename="schmobagel.dat"&lt;BR /&gt;&lt;BR /&gt;if [ -f $filename ]&lt;BR /&gt;then&lt;BR /&gt;  echo "not coing to copy $filename"&lt;BR /&gt;else&lt;BR /&gt;  cp /dir1/$filename /dir2&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;This concept will prevent you from overriting files that are in process of moving. Add it to your script.&lt;BR /&gt;&lt;BR /&gt;SEP&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Feb 2004 23:09:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180853#M162885</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2004-02-02T23:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: file active during ftp being processed.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180854#M162886</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;1. In the begining store the output of ls dir1 to a temporary file.&lt;BR /&gt;&lt;BR /&gt;2. For each file in the above temporary file use the mv to do the needful.&lt;BR /&gt;&lt;BR /&gt;sks</description>
      <pubDate>Tue, 03 Feb 2004 01:54:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180854#M162886</guid>
      <dc:creator>Sanjay Kumar Suri</dc:creator>
      <dc:date>2004-02-03T01:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: file active during ftp being processed.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180855#M162887</link>
      <description>I'm not sure I really understand SEP's solution here so it may well be the best idea.  SEP's often are :)&lt;BR /&gt; &lt;BR /&gt;Other than that, I'm not sure of a foolproof way you can do this so my suggestion is to just not mv the latest file in the directory as in&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;shift 1&lt;BR /&gt;for $file in $#&lt;BR /&gt;do&lt;BR /&gt;mv $file /dir2/$file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Call this script, eg. filemove.sh and run it from /dir1 with &lt;BR /&gt; &lt;BR /&gt;filemove.sh `ls -t`&lt;BR /&gt; &lt;BR /&gt;A bit messy though.</description>
      <pubDate>Tue, 03 Feb 2004 02:24:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180855#M162887</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-02-03T02:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: file active during ftp being processed.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180856#M162888</link>
      <description>FTP is pretty fast, so you could reasonably expect that, if the file modification time hasn't changed in, say, 120 seconds, then the remote server has finished FTPing the file:&lt;BR /&gt;&lt;BR /&gt;DELAY=120&lt;BR /&gt;PATH=/usr/bin&lt;BR /&gt;FLAG=/var/tmp/ftp_timestamp&lt;BR /&gt;rm -f $FLAG&lt;BR /&gt;touch $FLAG&lt;BR /&gt;cd /dir1&lt;BR /&gt;while true do&lt;BR /&gt;  sleep $DELAY&lt;BR /&gt;  for f in *&lt;BR /&gt;  do&lt;BR /&gt;    if [ -f "$f" -a "$f" -ot $FLAG ]&lt;BR /&gt;    then&lt;BR /&gt;      mv $f /dir2&lt;BR /&gt;    fi&lt;BR /&gt;  done&lt;BR /&gt;  touch $FLAG&lt;BR /&gt;done</description>
      <pubDate>Tue, 03 Feb 2004 03:51:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180856#M162888</guid>
      <dc:creator>Alan Turner</dc:creator>
      <dc:date>2004-02-03T03:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: file active during ftp being processed.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180857#M162889</link>
      <description>Ferdie,&lt;BR /&gt;&lt;BR /&gt;I guess you are save to mv when no process is accessing the file.&lt;BR /&gt;&lt;BR /&gt;So I would set it up like that&lt;BR /&gt;&lt;BR /&gt;targetdir=/target&lt;BR /&gt;sourcedir=/source&lt;BR /&gt;cd $sourcdir&lt;BR /&gt;# only files in that dir&lt;BR /&gt;for i in `ll | grep "^-" | awk '{print $9}'`&lt;BR /&gt;do&lt;BR /&gt;# only if no process is using them&lt;BR /&gt;if [ `fuser -u $i 2&amp;gt; /dev/null | grep -v "^$" | wc -l` -eq 0 ] ; then&lt;BR /&gt; mv $i $targetdir &lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Bernhard</description>
      <pubDate>Tue, 03 Feb 2004 04:34:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180857#M162889</guid>
      <dc:creator>Bernhard Mueller</dc:creator>
      <dc:date>2004-02-03T04:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: file active during ftp being processed.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180858#M162890</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I agree with what ever Bernhard has suggested. fuser is the best way to find if any process is using the file. &lt;BR /&gt;&lt;BR /&gt;fuser displays the user name if any process is using that file. So, the solution given by Bernhard is much suitable for your requirement.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;VJ.</description>
      <pubDate>Wed, 04 Feb 2004 05:47:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-active-during-ftp-being-processed/m-p/3180858#M162890</guid>
      <dc:creator>vasundhara</dc:creator>
      <dc:date>2004-02-04T05:47:31Z</dc:date>
    </item>
  </channel>
</rss>

