Trace log Migration for Oracle ____oracle

Source: Internet
Author: User
#!/bin/bash #-------------------------------------------------------------# Migrate the trace logs from Oracle to the data hard drive #----------- --------------------------------------------------# @author Alexander #------------------------------------------
-------------------# @time 20160105 #-------------------------------------------------------------# get trace log path alert_path=$1 # Get trace Log Migration destination path listener_path=$2 IF [[!-N $]] | | [[!-N $]];then echo ' log road strength and log migration destination path not set ' exit Fi # get all file functions under Directory function ergodic () {Local files = (' null ') local i=0 to file in ' ls $ |
                                Grep-e "Listener\.log" ' do if [-F $ '/' $file] Then
                files[$i]=$1 "/" $file fi let i++; Done # no trace log file exit script if [$i-eq 0]; Then Exit fi echo ${files[@]} lsnrctl set Log_status off files= ' ErgodIC $alert _path ' for file in ${files[*]} does # gets the last modification time of the log file modify= ' stat-c%Y $file 
                ' # Get time format year-month-day filedate= ' date-d ' @${modify} ' + '%y-%m-%d ' # Get time format date Filesec= ' date-d ' @${modify} ' + '%y%m%d%h%m%s ' # get log file path logpath=${file% * * Get log file name logname=${file##*/} # get file suffix name logext=${file#
                #*.} # to determine if the log storage path exists, and not to save the created if [! D-$ '/' $filedate]; Then ' mkdir $/' $filedate ' fi move log files to destination path ' MV $file $ "/" $filedate "/" $filesec ". $logext ' Done Lsnrctl set log_status on

Note:
This script starts with the LSNRCTL command, and if it encounters an error like that, it is an environment variable problem. The
needs to be added to the shell script (. Bash_profile less letter E in the picture) is mainly to join the ORACLE_HOME environment variable.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.