- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- file active during ftp being processed.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 02:46 PM
02-02-2004 02:46 PM
file active during ftp being processed.
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.
Ferdie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 03:09 PM
02-02-2004 03:09 PM
Re: file active during ftp being processed.
Use a tmp file as a semaphore, or if your app supports it, use file locking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 03:09 PM
02-02-2004 03:09 PM
Re: file active during ftp being processed.
if [ -f $filename ]
then
echo "not coing to copy $filename"
else
cp /dir1/$filename /dir2
fi
This concept will prevent you from overriting files that are in process of moving. Add it to your script.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 05:54 PM
02-02-2004 05:54 PM
Re: file active during ftp being processed.
1. In the begining store the output of ls dir1 to a temporary file.
2. For each file in the above temporary file use the mv to do the needful.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 06:24 PM
02-02-2004 06:24 PM
Re: file active during ftp being processed.
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
#!/usr/bin/sh
shift 1
for $file in $#
do
mv $file /dir2/$file
done
Call this script, eg. filemove.sh and run it from /dir1 with
filemove.sh `ls -t`
A bit messy though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 07:51 PM
02-02-2004 07:51 PM
Re: file active during ftp being processed.
DELAY=120
PATH=/usr/bin
FLAG=/var/tmp/ftp_timestamp
rm -f $FLAG
touch $FLAG
cd /dir1
while true do
sleep $DELAY
for f in *
do
if [ -f "$f" -a "$f" -ot $FLAG ]
then
mv $f /dir2
fi
done
touch $FLAG
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 08:34 PM
02-02-2004 08:34 PM
Re: file active during ftp being processed.
I guess you are save to mv when no process is accessing the file.
So I would set it up like that
targetdir=/target
sourcedir=/source
cd $sourcdir
# only files in that dir
for i in `ll | grep "^-" | awk '{print $9}'`
do
# only if no process is using them
if [ `fuser -u $i 2> /dev/null | grep -v "^$" | wc -l` -eq 0 ] ; then
mv $i $targetdir
fi
done
Regards,
Bernhard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2004 09:47 PM
02-03-2004 09:47 PM
Re: file active during ftp being processed.
I agree with what ever Bernhard has suggested. fuser is the best way to find if any process is using the file.
fuser displays the user name if any process is using that file. So, the solution given by Bernhard is much suitable for your requirement.
Regards
VJ.