- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: moving files from a dir which contains a HUGE ...
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
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
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
тАО07-29-2005 02:19 AM
тАО07-29-2005 02:19 AM
moving files from a dir which contains a HUGE amount
Filename is in Format YYYYMMDDHHmmss.some_other_stuff
so its easy to get the oldes files.
Now I need to move the 1000 oldest files (not timestamp, but filename) from there to another directory, where another process is working on them.
this is how we managed it:
ls -1 $XML_DIR | head -n 1000 | xargs -i mv ${XML_DIR}/{} ${WORK_DIR}/{}
It works, we dont get any "arg list too long errors"
But this executes mv for every File and thus takes a long time.
the -i option is my only chance to get the:
mv source target
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 02:29 AM
тАО07-29-2005 02:29 AM
Re: moving files from a dir which contains a HUGE amount
ls -1 $XML_DIR | head -n 1000 > filelist
# ser variable destdirectory
while read -r filename
do
mv $filename $destdirectory
done < filelist
This will get around the arg list too long error
SEP
Israel
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
тАО07-29-2005 02:37 AM
тАО07-29-2005 02:37 AM
Re: moving files from a dir which contains a HUGE amount
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 02:37 AM
тАО07-29-2005 02:37 AM
Re: moving files from a dir which contains a HUGE amount
Can you make the 'WORK_DIR' as a sub-directory on the same nfs/smb share ? This way there should be a link/unlink rather than a data copy.
just my 2-cents.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 02:48 AM
тАО07-29-2005 02:48 AM
Re: moving files from a dir which contains a HUGE amount
But with the filelist I get executed a single mv for each file.
But if I would get a filelist-File containing 10 filenames in a line, separated with blanks,
then each mv would move 10 files.
So I have to generate a filelist to give the following arguments to the mv:
mv file1 file2 file3 file4 file5 destination_dir
But how to do this ?
ls -x ?
how does this behave, when executed in Background (eg. not from a Terminal)?
Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 02:50 AM
тАО07-29-2005 02:50 AM
Re: moving files from a dir which contains a HUGE amount
Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 04:55 AM
тАО07-29-2005 04:55 AM
Re: moving files from a dir which contains a HUGE amount
while [ $i -le 100 ]
do
MOVELIST=`ls -1 | head -10`
mv $MOVELIST $WORKDIR
(( i=$i+1 ))
done
this should move 10 files at a time for 100 times totaling the movement of 1000 files with the same logic.
Hope this helps
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 05:00 AM
тАО07-29-2005 05:00 AM
Re: moving files from a dir which contains a HUGE amount
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 05:18 AM
тАО07-29-2005 05:18 AM
Re: moving files from a dir which contains a HUGE amount
ususally I use -l option in xargs
option -t can be used to trace the command
man xargs for more information
I created a small script movethem :
mv $* ${TARGET_DIR}
then
ls -1 $XML_DIR | head -n 1000 | xargs -l10 movethem
If you take the -t option you will see how often then mv command (or movethem script) is called
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 08:05 AM
тАО07-29-2005 08:05 AM
Re: moving files from a dir which contains a HUGE amount
So, are you sure it's only moving one file at a time? Did you watch it with ps?
Let's say it is doing only one at time - it's probably b/c you're using the argument replacement {} brackets. Although I've not checked it out by watching it with ps - this makes sense b/c I can't figure out how it would do it otherwise using replacement brackets.
Now, based on what I know, it seems that we could make it work if the xargs portion of the command ran more like | xargs mymovecommand (and therefore didn't use the brackets).
So we create a little command file:
cat > /var/tmp/processmove
mv $* $WORKDIR
ctrl-d
make it executable
chmod u+x processmove
Now...
ls -1 $XML_DIR | head -n 1000 | xargs /var/tmp/processmove
OK, you should be moving many many files at once now.
P.S. I put the "processmove" command in a shell script b/c I haven't yet figured out to make xargs accept passing commands to shell functions. My first inclination would naturally be to define
processmove () { move $* $WORKDIR }
and let xargs call that. But, I've never gotten that to work. Maybe someone else knows how to make xargs run a shell function.
P.P.S. If you're moving to a different file system - this is really going to load up the ol' I/O schedule. Also, if you do let it move to different file systems this way - you may want to defrag (if you've got online jfs) as this will be 1000 heavily interleaved/intertwined chained files. If you are moving these files to the same filesystem the above command(s) will not have any effect on fragmentation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2005 01:35 PM
тАО07-30-2005 01:35 PM
Re: moving files from a dir which contains a HUGE amount
can you create a number of 'moves' in the background and wait for there completion, then start up another set of 'moves' ?
my thinking is, the nfs share will be able to handle a number of threads concurrent, so why not try to run the jobs (only a few) in the background, until conpletion.
Then start up then set stage of jobs in the background, and then wait for completion.
Multitasking a few at a time, might do the trick for the CIFS server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2005 10:30 PM
тАО08-03-2005 10:30 PM
Re: moving files from a dir which contains a HUGE amount
I managed it this way:
ls -1 DIR |head -n 1000 | sed "s:^\(.*\)$:DIR/\1:" | xargs -L 20 echo | sed "s:^\(.*\)$:\1 DIR2:" | xargs -l mv
this helped us a lot.
Points will follow
Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2005 10:31 PM
тАО08-03-2005 10:31 PM
Re: moving files from a dir which contains a HUGE amount
Thanks