- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- What happens with files being created while I'm mo...
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
03-03-2006 12:18 AM
03-03-2006 12:18 AM
mydir="/.../admin/arch"
mv mydir/* /NFS_MOUNT_POINT/ARCH_PROD
What happens if a file is being created in mydir while files get moved? Is the file moved as it is, without ending his creation??
Best Regards,
Eric Antunes
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 12:30 AM
03-03-2006 12:30 AM
Re: What happens with files being created while I'm moving all files in the directory?
Your regular expression is going to be expanded when the shell processes the "mydir/*", resulting in a list of files present at that partiular moment in time. Files added to the directory after that will be ignored.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 12:33 AM
03-03-2006 12:33 AM
SolutionThe steps to removal of a file all relate to the directory, not the contents. A file can disappear (be removed) from the directory but if it is still open, the program(s) will still be able to access the file. When a file is first opened, all the information needed to access the file is stored in the program's file descriptor, so the directory is no longer needed. Once the file is completely closed, then the inodes pointing to the file are marked as unused in the directory.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 12:34 AM
03-03-2006 12:34 AM
Re: What happens with files being created while I'm moving all files in the directory?
Session 1:
mkdir /var/tmp/test
cd /var/tmp/test
dd if=dev/zero of=bigfile
Session 2:
cd /var/tmp
mv test test.bak -----> sucess
ls test.bak
bigfile
Session 1:
pwd
permission denied
Conclusion: Because the movement is on the same file system, the directory is moved and the file keeps growing (writing data). After that, the path is invalid and you will get permission denied. The data is available on the new path.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 12:37 AM
03-03-2006 12:37 AM
Re: What happens with files being created while I'm moving all files in the directory?
I tested in this way:
Session 1:
mkdir /var/tmp/test
cd /var/tmp/test
dd if=dev/zero of=bigfile
Session 2:
cd /var/tmp
mv test /usr/tmp -----> Waiting for the write command to finish
Session 1:
CTRL+C ------------> Session 2 finished the move of the directory
pwd
permission denied
Conclusion: Because the movement is on the differents file systems, the directory is moved after the open file is closed. After that, the path is invalid and you will get permission denied. The data is available on the new path.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 12:44 AM
03-03-2006 12:44 AM
Re: What happens with files being created while I'm moving all files in the directory?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 02:14 AM
03-03-2006 02:14 AM
Re: What happens with files being created while I'm moving all files in the directory?
That was the behaviour I was expecting but since I have the database in archive mode and a different behaviour could crash it, I wanted to be sure. :)
Best Regards,
Eric Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 02:20 AM
03-03-2006 02:20 AM
Re: What happens with files being created while I'm moving all files in the directory?
find $mydir -name "*.arc" -ctime +14 -exec mv /NFS_MOUNT_POINT/ARCH_PROD
Best Regards,
Eric Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 02:21 AM
03-03-2006 02:21 AM
Re: What happens with files being created while I'm moving all files in the directory?
Be careful here.
Consider that a 'mv' can be a simple ;rename(2)' or a copy and remove ('unlnk(2)'). A rename occurs only if file remains in the *same* filesystem.
If you 'mv' within a filesystem, then the data being added by your process to its file continues to be written into the renamed file (same inode). That is, your process creates a file with the same data that it would have had the file not been renamed.
If, however, your 'mv' occurs accross filesystems, then the final file contents will only reflect what you had at the time the copy occured. New data created by your process after the moment of the copy will be lost.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 02:26 AM
03-03-2006 02:26 AM
Re: What happens with files being created while I'm moving all files in the directory?
I would use
"find $mydir -name "*.arc" -mtime +14 -exec mv /NFS_MOUNT_POINT/ARCH_PROD {} \;"
-or-
"find $mydir -name "*.arc" -mtime +14 |xargs mv /NFS_MOUNT_POINT/ARCH_PROD "
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 02:49 AM
03-03-2006 02:49 AM
Re: What happens with files being created while I'm moving all files in the directory?
"If, however, your 'mv' occurs accross filesystems, then the final file contents will only reflect what you had at the time the copy occured. New data created by your process after the moment of the copy will be lost."
That's the situation: I want to move the archivelog files from a server to another (via NFS).
You are telling me that:
mv $mydir/* /NSF_MOUNT_POINT/ARCHPROD
is different than:
find $mydir -name "*.arc" -ctime +14 -exec mv {} \;
Those 2 expressions acts differently??
Thanks,
Eric Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 02:50 AM
03-03-2006 02:50 AM
Re: What happens with files being created while I'm moving all files in the directory?
find $mydir -name "*.arc" -ctime +14 -exec mv {} \;
I wanted to write:
find $mydir -name "*.arc" -ctime +14 -exec mv /NFS_MOUNT_POINT/ARCH_PROD {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 03:02 AM
03-03-2006 03:02 AM
Re: What happens with files being created while I'm moving all files in the directory?
Yes, I am saying that if you are crossing mountpoints, then executing a 'mv' command becomes a copy and not a 'rename' and what I said previously applies.
If you have an active process that is writing to a file, you do not want to move/copy the file until you are finished writing to it.
One way to handle this kind of situation is to preface the move/copy with a test that attempts to see if any process is using the file. I have used 'fuser' to look for processes actively associated with the file in situations like this. If the file is inuse, wait until its not and then copy it, or skip it entirely.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2006 03:34 AM
03-03-2006 03:34 AM
Re: What happens with files being created while I'm moving all files in the directory?
Since, I'm sure that no process will be writing to files with more than 1 day since the files are just created and never changed (they are archive logs), I will use the find first and move (copy and delete) just files older than 14 days:
find $mydir -name "*.arc" -ctime +14 -exec mv /NFS_MOUNT_POINT/ARCH_PROD {} \;
Thanks to all,
Eric Antunes