DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Getting date of file through utl file or some other means

  1. #1
    Join Date
    Aug 2002
    Location
    Atlanta
    Posts
    1,187

    Getting date of file through utl file or some other means

    Morning,
    I have a procedure that reads a dozen or so log files and then sends me the last 10 lines of each log file in a single email with utl_file. I can easily check on batch jobs, export status etc this way in one email.

    Is there anyway I can read the date of the file I am parsing?

    ie, I read the entire log into a temp table, then use a little FOR loop to write out the last 10 lines of the file. What if my batch job does not run? The procedure will stil send me the log info but I will have no way of knowing whether the log is current or not.

    Thanks

    Steve
    I'm stmontgo and I approve of this message

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    You can't get file's creation/modification date without using java or some external procedure calls.

    If you don't want to do this java/extproc stuff, you'll have to modify your batch jobs to write a timestamp at the end of each logfile - that way you'll easily recognize if logfile is current or not. That shouldn't be too hard.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Aug 2002
    Location
    Atlanta
    Posts
    1,187
    Originally posted by jmodic
    You can't get file's creation/modification date without using java or some external procedure calls.

    If you don't want to do this java/extproc stuff, you'll have to modify your batch jobs to write a timestamp at the end of each logfile - that way you'll easily recognize if logfile is current or not. That shouldn't be too hard.
    yeah thanks, rman shows the date but export does not so after my export I add a dir >>
    to add the file info at the end of the export log

    thanks

    steve
    I'm stmontgo and I approve of this message

  4. #4
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    You can easily "force" the exp utility to include the timestamp of the beginning of the export in the log file. Oracle's exp and imp (and some other utilities) have a very peculiar and unfortunate habit of redirecting some parts of the output to stderr pipe and not to standard output as you would expect. And the header of the exp log output (where the current timestamp is displayed) is one of those parts. If you specify LOG=log.txt when running exp, then only standard output is redirected into the log file. And you won't find any timestamp in there. Here is an example of such a log file that was created with the following exp command line:
    c:\exp scott/tiger@o901 file=emp.dmp tables=emp log=log.txt
    Code:
    Connected to: Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
    With the Partitioning option
    JServer Release 9.0.1.1.1 - Production
    Export done in EE8MSWIN1250 character set and AL16UTF16 NCHAR character set
    
    About to export specified tables via Conventional Path ...
    . . exporting table                            EMP         14 rows exported
    Export terminated successfully without warnings.
    But if instead of this you redirect the standard error pipe to the log file you get the complete output (as you get on the screen when running exp manualy), together with the timestamp information in the first line (this stderr redirection example is valid for Windows, but it is practicaly the same on Unix):
    C:\>exp scott/tiger@o901 file=emp.dmp tables=emp 2>log.txt
    Code:
    Export: Release 9.0.1.1.1 - Production on Po Mar 22 19:45:32 2004
    
    (c) Copyright 2001 Oracle Corporation.  All rights reserved.
    
    
    Connected to: Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
    With the Partitioning option
    JServer Release 9.0.1.1.1 - Production
    Export done in EE8MSWIN1250 character set and AL16UTF16 NCHAR character set
    
    About to export specified tables via Conventional Path ...
    . . exporting table                            EMP         14 rows exported
    Export terminated successfully without warnings.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width