- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- log of deleted files
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
09-12-2002 11:01 PM
09-12-2002 11:01 PM
log of deleted files
I have a cron job script to delete output reports files from a directory older than 20 using the following command:
>>>
find . -mtime +1 -exec ll {} \;
find . -mtime +1 -exec rm {} \;
<<<
Is there a way that I can log all the files deleted in one single command rather than have two file sweeps.
Thanks very much in advance,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2002 11:06 PM
09-12-2002 11:06 PM
Re: log of deleted files
try the following command:
find . -mtime +1 -exec ls -A {} \; | tee log_file | xargs rm
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2002 11:16 PM
09-12-2002 11:16 PM
Re: log of deleted files
just consider that using xargs is limited by the total count of the argument list. Therefore it doesn't work if there are too many files.
By, Ulf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2002 11:44 PM
09-12-2002 11:44 PM
Re: log of deleted files
how about this command:
find . -mtime +1 -exec ls -A {} \; |tee log_files | awk '{print "rm "$1}' |sh
I guess there will not be restrictions as Ulf pointed out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 12:01 AM
09-13-2002 12:01 AM
Re: log of deleted files
the main use of xargs is to avoid having to much arguments to a command. with the xargs option -n you can specify how many argument you want to give to each execution of the specified command.
But another problem you will face with the xargs solution are blanks in a filename. i would use the following command:
find . -mtime +1 | tee -a /path/to/mylogfile | xargs -i rm "{}"
Heiner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 03:13 AM
09-13-2002 03:13 AM
Re: log of deleted files
find . -mtime +1 -print -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 04:29 AM
09-13-2002 04:29 AM
Re: log of deleted files
For your example:
find . -mtime +1 -exec ll {} \; -exec rm {} \;
You may want to add the "-d" option to "ll" if you have sub-directories. Or you chould use "-type f" option for the find.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 10:19 AM
09-13-2002 10:19 AM
Re: log of deleted files
find . -mtime -1 -exec ll {} \; -exec rm {} \;
Just make sure the rm is last or the ll won't work. They are executed in order.
This will retain your previuos behavior as well (i.e. output in the mail from cron, not some other log file)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 10:35 AM
09-13-2002 10:35 AM
Re: log of deleted files
You can also use the '-t' (trace) option of 'xargs' to echo to stderr the command that will be executed, in this case thereby capturing a log of those files which are removed:
# find . -mtime +1 -type f xargs -L 500 -t -i rm {} 2> /tmp/removedfiles
I've added the '-L' option to 'xargs' to limit the number of arguments processed during each interation. This avoids the argument-too-long problem, particularly on 10.x releases.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 10:59 AM
09-13-2002 10:59 AM
Re: log of deleted files
I'm sorry, I dropped a pipe. The command should read:
# find . -mtime +1 -type f | xargs -L 500 -t -i rm {} 2> /tmp/removedfiles
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 11:41 AM
09-13-2002 11:41 AM
Re: log of deleted files
will work too. You can alway redirect the output to a file.
HTH
Marty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 06:19 PM
09-13-2002 06:19 PM
Re: log of deleted files
uuencode /tmp/logfiles logfiles.txt | xmail -m -s "log of deleted files" yourname@your.com someonelsesname@your.com
live free or die
harry