14 Replies Latest reply on May 27, 2019 6:23 AM by Quanwen Zhao

    How to extract listener log file's path?

    Quanwen Zhao

      Hey guys and friends ,

       

      Currently I wanna write a Shell script for mining all of listener log files with xml format to review App servers's IP addresses. You know, I've found the listener file's location.

       

      [oracle@xxxx ~]$ lsnrctl status | grep "Listener Log File"
      Listener Log File         /u01/app/oracle/diag/tnslsnr/xxxx/listener/alert/log.xml
      [oracle@xxxx ~]$
      [oracle@xxxx ~]$ lsnrctl status | grep "Listener Log File" | awk -F' ' '{print $NF}'
      /u01/app/oracle/diag/tnslsnr/xxxx/listener/alert/log.xml
      

       

      So, the listener log file's path is "/u01/app/oracle/diag/tnslsnr/xxxx/listener/alert". As you can see where I can find all of the listener log's xml files.

       

      [oracle@xxxx ~]$ cd /u01/app/oracle/diag/tnslsnr/xxxx/listener/alert
      [oracle@xxxx alert]$ 
      [oracle@xxxx alert]$ ls -lth
      -rw-r----- 1 oracle oinstall 2.2M May 23 17:27 log.xml
      -rw-r----- 1 oracle oinstall  11M May 23 09:51 log_218.xml
      -rw-r----- 1 oracle oinstall  11M May 21 22:41 log_217.xml
      -rw-r----- 1 oracle oinstall  11M May 20 11:31 log_216.xml
      -rw-r----- 1 oracle oinstall  11M May 19 00:21 log_215.xml
      -rw-r----- 1 oracle oinstall  11M May 17 13:11 log_214.xml
      -rw-r----- 1 oracle oinstall  11M May 16 02:04 log_213.xml
      -rw-r----- 1 oracle oinstall  11M May 14 14:59 log_212.xml
      -rw-r----- 1 oracle oinstall  11M May 13 03:51 log_211.xml
      -rw-r----- 1 oracle oinstall  11M May 11 16:41 log_210.xml
      ......
      -rw-r----- 1 oracle oinstall  11M Jun 12  2018 log_10.xml
      -rw-r----- 1 oracle oinstall  11M Jun 11  2018 log_9.xml
      -rw-r----- 1 oracle oinstall  11M Jun 10  2018 log_8.xml
      -rw-r----- 1 oracle oinstall  11M Jun  8  2018 log_7.xml
      -rw-r----- 1 oracle oinstall  11M Jun  7  2018 log_6.xml
      -rw-r----- 1 oracle oinstall  11M Jun  6  2018 log_5.xml
      -rw-r----- 1 oracle oinstall  11M Jun  5  2018 log_4.xml
      -rw-r----- 1 oracle oinstall  11M Jun  5  2018 log_3.xml
      -rw-r----- 1 oracle oinstall  11M Jun  5  2018 log_2.xml
      -rw-r----- 1 oracle oinstall  11M Jun  5  2018 log_1.xml
      

       

      Now how to extract listener log file's path for me using AWK or CUT or other shell command on my Linux server?

       

      Any help very appreciated.

       

      Best Regards

      Quanwen Zhao