- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: find command: replace exec to xargs problem
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
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
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-21-2003 03:30 AM
тАО03-21-2003 03:30 AM
find command: replace exec to xargs problem
I want to replace the exec to xargs in find command, because every time when I run the command CPU is overloaded.
find . -name "*.day.*" -exec cp -r {} /store \; -exec rm -f {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 03:39 AM
тАО03-21-2003 03:39 AM
Re: find command: replace exec to xargs problem
find . -name "*.day.*" |xargs cp -r;find . -name "*.day.*" |xargs rm -f
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 03:47 AM
тАО03-21-2003 03:47 AM
Re: find command: replace exec to xargs problem
I try to change it into the next syntax, but the CPU load still HIGH.
find . -name "*.day.*" | xargs -i cp -r "{}" /store | xargs -i rm -f
By the way, do I need to use -i and "{}"???
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 03:53 AM
тАО03-21-2003 03:53 AM
Re: find command: replace exec to xargs problem
find . -name "*.day.*"
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 04:02 AM
тАО03-21-2003 04:02 AM
Re: find command: replace exec to xargs problem
How many files and directories are in the directory tree at the point where you run the find command?
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 04:03 AM
тАО03-21-2003 04:03 AM
Re: find command: replace exec to xargs problem
It looks like running 2 find command in the same time, it will generate CPU overload.
Reschedule the scripts in the crontab is not possible.
So any idea how to rebuild the find command??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 04:05 AM
тАО03-21-2003 04:05 AM
Re: find command: replace exec to xargs problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 04:16 AM
тАО03-21-2003 04:16 AM
Re: find command: replace exec to xargs problem
How about trying:
find . -name "*.day.*" | xargs -i echo "cp -r {} /store;rm -f {}" |sh
rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 04:21 AM
тАО03-21-2003 04:21 AM
Re: find command: replace exec to xargs problem
Why don't you do the following :
for i in `find ./ -name "*.day.*"`
do
cp -r $i /store
rm -f $i
done
Groeten/Regs,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 04:24 AM
тАО03-21-2003 04:24 AM
Re: find command: replace exec to xargs problem
What about :
find ./ -name "*.day.*" -exec mv {} /store \;
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 04:38 AM
тАО03-21-2003 04:38 AM
Re: find command: replace exec to xargs problem
find ./ -name "*.day.*" -exec mv {} /store \;
If I translate it into xargs. should it be like this??
find . -name "*.day.*" | xargs -i mv ./{} /store/{}
The advantage of using "xargs" instead of "exec" is that it save the CPU time or not? if you have a lot of file to find. please confirm this
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 04:53 AM
тАО03-21-2003 04:53 AM
Re: find command: replace exec to xargs problem
The advantage to 'xargs' over 'exec' in situations like you describe is really two-fold. First, you avoid the potential for an "argument list too long". Secondly, and more importantly, you avoid forking a separate task for every argument processed.
Another often overlooked ability of 'xargs' to bundle, as many arguments as specified by its '-n number' option together into a single execution.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 05:56 AM
тАО03-21-2003 05:56 AM
Re: find command: replace exec to xargs problem
this works.
find ./ -name \*.day.\* -exec /usr/bin/mv {} /store \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2003 06:33 AM
тАО03-21-2003 06:33 AM
Re: find command: replace exec to xargs problem
it has to traverse the I/O super block tables and find what you are looking for
you can nice this process so that it gets whatever cpu is left over
you can cd to the directory you are finding stuff in and then do the find
you have to find (pun intended) ways to reduce the number of I/O trees that the command is searching thru to find what you want