oracle的trace日誌遷移____oracle

來源:互聯網
上載者:User
#!/bin/bash#-------------------------------------------------------------# 將oracle產生的trace日誌遷移至資料硬碟#-------------------------------------------------------------# @author alexander#-------------------------------------------------------------# @time 20160105#-------------------------------------------------------------# 擷取trace日誌路徑alert_path=$1# 擷取trace日誌遷移目的路徑listener_path=$2if [[ ! -n $1  ]] || [[ ! -n $2  ]];then        echo "日誌路勁和日誌遷移目的路徑未設定"        exitfi# 擷取目錄下所有檔案函數function ergodic(){        local files=('null')        local i=0        for file in `ls $1 | grep -E "listener\.log"`                do                        if [ -f $1"/"$file ]                        then                                files[$i]=$1"/"$file                        fi                        let i++;                done        # 沒有trace記錄檔退出指令碼        if [ $i -eq 0 ]; then                exit        fi        echo ${files[@]}}lsnrctl set log_status offfiles=`ergodic $alert_path`for file in ${files[*]}        do                # 擷取記錄檔最後修改時間                modify=`stat -c %Y $file`                # 擷取時間格式年-月-日                filedate=`date -d "@${modify}" +"%Y-%m-%d"`                # 擷取時間格式年月日時分秒                filesec=`date -d "@${modify}" +"%Y%m%d%H%M%S"`                # 擷取記錄檔路徑                logpath=${file%/*}                # 擷取記錄檔名                logname=${file##*/}                # 擷取檔案尾碼名                logext=${file##*.}                # 判斷日誌儲存路徑是否存在,不存見建立之                if [ ! -d $2"/"$filedate ]; then                        `mkdir $2"/"$filedate`                fi                # 將記錄檔移動到目的路徑                `mv $file $2"/"$filedate"/"$filesec"."$logext`        donelsnrctl set log_status on

注意:
本指令碼啟動須使用lsnrctl命令,如果遇到之類的錯誤,是環境變數的問題。
需要在shell指令碼中加入(圖片中的.bash_profile少個字母e)主要是加入ORACLE_HOME這個環境變數。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.