- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script help – record all files deleted by the scri...
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
04-20-2006 01:12 AM
04-20-2006 01:12 AM
I would like to log or record all files/directories removed by this shell script.
#!/usr/bin/sh
function purge_logs
{
find $1 -mtime +$2 -exec rm -rf {} \;
}
purge_logs /psoft/hrcat88a/LOGS 30
purge_logs /psoft/hrcat88b/LOGS 60
purge_logs /psoft/hrcat88c/LOGS 90
exit 0
Thanks,
Gulam.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2006 01:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2006 01:22 AM
04-20-2006 01:22 AM
Re: Script help – record all files deleted by the script.
find $1 -mtime +$2 -print -exec rm -rf {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2006 01:33 AM
04-20-2006 01:33 AM
Re: Script help – record all files deleted by the script.
LOG=/tmp/yourlogfile
find $1 -mtime +$2 -print -exec rm -rf {} \; |tee $LOG
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2006 01:35 AM
04-20-2006 01:35 AM
Re: Script help – record all files deleted by the script.
Another way is this:
# find
The 'xargs -t' enables tracing of the command that is executed. Even more importantly, it bundles multiple file arguments to 'rm'. This eliminates a 1:1 number of execs of a separate 'rm' for every argument found by 'find'. Process creation is very, very expensive. Using 'xargs' in lieu of '-exec' with 'find' will greatly improve performance.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2006 08:06 PM
04-20-2006 08:06 PM
Re: Script help – record all files deleted by the script.
you can use this way:
#!/usr/bin/sh
function purge_logs
{
find $1 -mtime +$2 -exec rm -rf {} \;
}
{
purge_logs /psoft/hrcat88a/LOGS 30
purge_logs /psoft/hrcat88b/LOGS 60
purge_logs /psoft/hrcat88c/LOGS 90
} >logfile 2>&1
exit 0
Thsi will write inti logfile all the output, including errors, comining from the 2 purge_logs.
HTH,
Art