- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to delete log files older than 3 days.
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
тАО10-08-2000 06:36 AM
тАО10-08-2000 06:36 AM
I will put this scrip in crontab which will run everyday night after backups and delete those archive log files older than 3 days.
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2000 06:56 AM
тАО10-08-2000 06:56 AM
Re: Script to delete log files older than 3 days.
Here's two ways:
# find / -name *.ARC -mtime +3 -exec rm -f {} \;
The above will remove all files ending in ".ARC" that were modified 3-days ago or more.
Another variation is to create a reference file with a certain date and time. Consider:
# cd /ora_arch
# touch -m -t 10050000 f.$$ #...Oct 5th at 0000 hours..
# find *.ARC -newer f.$$ -exec rm -f {} ;
# rm f.$$
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2000 09:09 AM
тАО10-08-2000 09:09 AM
Re: Script to delete log files older than 3 days.
Ah, a few helpful clarifications:
(1) It is best, with 'find' to quote metacharacters. Thus:
# find / -name "*.ARC" -mtime +3 -exec rm -f {} \;
You could also be more specific with the starting directory in the above, e.g. /ora_arch
(2) In the second example I gave you, you would want to NEGATE (!) the 'newer' operator since 'newer
# cd /ora_arch
# touch -m -t 10050000 f.$$ #...Oct 5th at 0000 hours..
# find . -name "*.ARC" ! -newer f.$$ -exec rm -f {} \;
# rm f.$$
(3) NOTE that the implicit time in the first example is the current time (hhmm). Thus, 3-days in our example is measured as three (3) twenty-four (24) hours increments from the hour and minute the find command is initiated.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2000 10:51 AM
тАО10-08-2000 10:51 AM
SolutionDON'T DO IT.
Many servers are crushed when new users read a Unix For Newbies book and look for files using find /. This command will search through every gigabyte of data on CDROMs, NFS mount points and hundreds of gigabytes of database information. Not good.
When users are looking for some file, have them narrow the search to where the files are really located. Users cannot write files into HP-UX directories like /etc amd /opt so there's no need to overload the server with useless disk activities.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2000 11:16 AM
тАО10-08-2000 11:16 AM
Re: Script to delete log files older than 3 days.
Thanks Bill! Yes, heed Bill's advise carefully about "find / ...". If you have a development server, simply time the difference with and without a SupportPlus CD mounted.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2000 10:49 PM
тАО10-08-2000 10:49 PM
Re: Script to delete log files older than 3 days.
Remember that archive log files are needed for database recovery. Better than a time based remove use a backup based remove.
List backuped archive log files on yur backup precedure and then remove it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2000 01:50 AM
тАО10-09-2000 01:50 AM
Re: Script to delete log files older than 3 days.
My advise is to list the files to be removed into a file and then remove them. You acn have a look at the file and if need be copy back from tape. You can include this in a script:
find /LIVEORAB ( -name '*.ARC' -o -name '*.log' ) -mtime +3 -print > /LIVEORAB/bkup_graph1
find /oracle ( -name '*.ARC' -o -name '*.log' )-mtime +3 -print > /LIVEORAB/bkup_graph2
Then you can do a remove with this command:
find /oracle /LIVEORAB ( -name '*.ARC' -o -name '*.log' )-mtime +3 -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2000 01:59 AM
тАО10-09-2000 01:59 AM
Re: Script to delete log files older than 3 days.
The lines should read:
find /oracle /LIVEORAB \( -name '*.ARC' -o -name '*.log' \) -mtime +3 -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2000 06:46 AM
тАО10-09-2000 06:46 AM
Re: Script to delete log files older than 3 days.
On those rare and annoying occassions when you simply must search every mounted filesystem for a file, please use
du -a / | grep "filename$"
It is much faster and less resource intensive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2000 12:45 AM
тАО10-10-2000 12:45 AM
Re: Script to delete log files older than 3 days.
Archived redologs resides where log_archive_dest parameter form init$ORACLE_SID.ora points.
You can restrict find to that directory
log_archive_dest = /archived_redo