- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: new to cron, scheduled find & delete
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
07-06-2004 12:51 PM
07-06-2004 12:51 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:01 PM
07-06-2004 01:01 PM
Solutione.g. find /filesystem -name
you can use wilcards as well
find /filesystem/directory -name "*filename*" -exec rm {} \;
So in cron to run everyday at 15:44
44 15 * * * /usr/bin/find /filesystem/directory -name "*filename*" -exec rm {} \;
You also set this up in a script as well and point cron to the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:07 PM
07-06-2004 01:07 PM
Re: new to cron, scheduled find & delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:22 PM
07-06-2004 01:22 PM
Re: new to cron, scheduled find & delete
No it doesn't tell you the files that were deleted.
Maybe run another find prior to this and send output to file so you have a record:
find /
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:24 PM
07-06-2004 01:24 PM
Re: new to cron, scheduled find & delete
find /hostingdir -name *.xls -print | xargs ls {} \; > /tmp/files2del.txt
for i in `cat /tmp/files2del.txt`
do
rm $i
done
Replace *.xls with whatever...
Note - the reason to use xargs instead of exec is right in the man page for find:
Note that output from find was piped to xargs(1) instead of using
the -exec primary. This is because when a large number of files
or directories is to be processed by a single command, the -exec
primary spawns a separate process for each file or directory,
whereas xargs collects file names or directory names into
multiple arguments to a single chmod command, resulting in fewer
processes and greater system efficiency.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:24 PM
07-06-2004 01:24 PM
Re: new to cron, scheduled find & delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:31 PM
07-06-2004 01:31 PM
Re: new to cron, scheduled find & delete
find /hostingdir -name *.xls -print | xargs rm {} \; > /tmp/files2del.txt
I thought you might want 2 scripts - run the find the first night, then next day, check the contents prior to removing....
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:31 PM
07-06-2004 01:31 PM
Re: new to cron, scheduled find & delete
You can of course run a script to get the contents of the directory and place them in a file before you delete them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:35 PM
07-06-2004 01:35 PM
Re: new to cron, scheduled find & delete
# find / -name *.html -print | xargs ls {} \; >/tmp/files.txt
# head -25 /tmp/files.txt
/home/Inetpub/wwwroot/banner.html
/home/Inetpub/wwwroot/index1.html
/home/Inetpub/wwwroot/index2.html
/home/Inetpub/wwwroot/indexf.html
/home/Inetpub/wwwroot/index.html
/home/Inetpub/wwwroot/mhpo/11thconvagenda.html
/home/Inetpub/wwwroot/mhpo/11thconv.html
/home/Inetpub/wwwroot/mhpo/11thconvspeak.html
/home/Inetpub/wwwroot/mhpo/12thconv.html
/home/Inetpub/wwwroot/mhpo/benefits.html
/home/Inetpub/wwwroot/mhpo/board.html
/home/Inetpub/wwwroot/mhpo/bullnews.html
/home/Inetpub/wwwroot/mhpo/cariboo.html
/home/Inetpub/wwwroot/mhpo/classifieds.html
/home/Inetpub/wwwroot/MIS-NEW1/aboutus.html
/home/Inetpub/wwwroot/MIS-NEW1/index1.html
/home/Inetpub/wwwroot/MIS-NEW1/index.html
/home/Inetpub/wwwroot/MIS-NEW1/products.html
/home/Inetpub/wwwroot/MIS-NEW1/services.html
/home/Inetpub/wwwroot/MIS-NEW2/spry.html
/home/Inetpub/wwwroot/MIS-NEW/help.html
/home/Inetpub/wwwroot/MIS-NEW/index.html
/home/Inetpub/wwwroot/MIS-NEW/links.html
/home/Inetpub/wwwroot/MIS-NEW/news.html
/home/Inetpub/wwwroot/MIS-NEW/Smokey.html
Works for me...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:36 PM
07-06-2004 01:36 PM
Re: new to cron, scheduled find & delete
find public_html/ -name *.mp3 -print | exec rm {} \; >> /tmp/find_delete.log
im just trying to get this actually in my memory, so i dont have to ask all this again, sorry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:41 PM
07-06-2004 01:41 PM
Re: new to cron, scheduled find & delete
Geoff
I think what Michael means is that 'xargs' works if files exist. If there is no files to find it returns everything in the directory
eg find . -name "file_doesnt_exist" -print | xargs ls
Rob
Use 2 find commands:
find public_html/ -name *.mp3 -exec ls -l {} \; >> /tmp/find_delete.log
find public_html/ -name *.mp3 -exec rm {} \;
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:41 PM
07-06-2004 01:41 PM
Re: new to cron, scheduled find & delete
# find /tmp -name *.unknownfile -print | xargs ls {} \; >/tmp/files.txt
# cat /tmp/files.txt
#
Returns nothing - so even it it was rm instead of ls - then it wouldn't remove anything...
As a test (don't do this at home!!):
cd tmp
ls >tmp.files
cat tmp.files
backup.log
files.txt
ftpdunebackup.log
lost+found
makewhatisNUWseo
orbit-root
tmp.files
find /tmp -name *.unknownfile -print | xargs rm {} \; >/tmp/files.txt
rm: cannot remove `{}': No such file or directory
rm: cannot remove `;': No such file or directory
[root@arrakis tmp]# ls
backup.log ftpdunebackup.log makewhatisNUWseo tmp.files
files.txt lost+found orbit-root
Well - it didn't delete anything....
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:44 PM
07-06-2004 01:44 PM
Re: new to cron, scheduled find & delete
find public_html/ -name *.mp3 -print | exec rm {} \; >> /tmp/find_delete.log
should be:
find /public_html -name "*mp3" -print | exec rm {} \; >> /tmp/find_delete.log
You must use double quotes for wildcards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 03:33 PM
07-06-2004 03:33 PM
Re: new to cron, scheduled find & delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 04:18 PM
07-06-2004 04:18 PM
Re: new to cron, scheduled find & delete
find /tmp \( -name '*.wav' -o -name '*.mp3' \) -print | xargs rm {} \; >/tmp/files.txt
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 07:07 PM
07-06-2004 07:07 PM
Re: new to cron, scheduled find & delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 07:13 PM
07-06-2004 07:13 PM
Re: new to cron, scheduled find & delete
expression -o expression: Logical OR operator. True if either or both of the expressions are true.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 07:31 PM
07-06-2004 07:31 PM
Re: new to cron, scheduled find & delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 09:47 PM
07-06-2004 09:47 PM
Re: new to cron, scheduled find & delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 10:02 PM
07-06-2004 10:02 PM
Re: new to cron, scheduled find & delete
find /public_html -name "*avi" -print
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2004 12:59 AM
07-07-2004 12:59 AM
Re: new to cron, scheduled find & delete
Welcome to the forum by the way.
Be sure to read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#overview
And then assign points to those that have helped you.
Thanks...Geoff