- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Script help
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
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-13-2008 01:03 PM
тАО03-13-2008 01:03 PM
Shell Script help
I need to write a shell script that connects to oracle and queries a datadictionary to get a filename. Now the script has to delete all the files on the unix box that were created before the creation_timestamp of the filename returned.
Can someone please send me a sample code?
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2008 01:40 PM
тАО03-13-2008 01:40 PM
Re: Shell Script help
First, there is no such thing in Unix as a "creation" timestamp. You have a "last modification" time that represents a creation moment when I file or directory is first instantiated. Thereafter, any change in the file or directory contents updates the modification timestemp.
That said:
# find /path -xdev -type f ! -newer reffile -exec rm {} \+
This will find files ('-type f') in '/path' while not crossing mountpoints ('-xdev') that are not more recently modified ('! -newer') than a 'reffile' that you can create or already exists. File meeting these criteria will be removed.
Should you need to create a "reference file", simply do:
# touch -amt yymmddhhmm reffile
...for example for February 29 at 1300 hours:
# touch -amt 0802291300 reffile
See the manpages for 'find' and 'touch' for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2008 01:41 PM
тАО03-13-2008 01:41 PM
Re: Shell Script help
http://forums.oracle.com/forums/categoryHome.jspa?categoryID=84
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2008 02:06 PM
тАО03-13-2008 02:06 PM
Re: Shell Script help
The find command you gave me also include the filename in the result set. Is it possible to exclude this file from the result as I need the files modified before "this" file. and I need only files with *.arc to be removed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2008 02:12 PM
тАО03-13-2008 02:12 PM
Re: Shell Script help
> [...]
Put it somewhere where "find" won't find it?
touch -amt yymmddhhmm /tmp/reffile
[...] -newer /tmp/reffile
If you use "/tmp" (or some other common
location), you might wish to throw a process
ID into the file name, in case you try this
twice at the same time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2008 02:31 PM
тАО03-13-2008 02:31 PM
Re: Shell Script help
> The find command you gave me also include the filename in the result set. Is it possible to exclude this file from the result as I need the files modified before "this" file. and I need only files with *.arc to be removed.
Well, you didn't specify those elements, but that's easily done:
...for example for February 29 at 1300 hours:
# touch -amt 0802291300 /var/tmp/reffile
# find /path -xdev -type f -name "*.arc" ! -newer /var/tmp/reffile -exec rm {} \+
Note that the '-name' argument is quoted so that the shell doesn't expand the wildcard characters before 'find' has an opportunity to evaluate it.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2008 07:55 PM
тАО03-13-2008 07:55 PM
Re: Shell Script help
Which version of Oracle are you running?
All this pain of writing a script to do this unhealthy maintenance can be avoided by using RMAN to backup your archived log files and automatic purging.
revert.
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2008 06:23 AM
тАО03-14-2008 06:23 AM