#!/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.