Difference between revisions of "Maintenance"

From dbawiki
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
* [[Purging trace and dump files in 11g with adrci]]
 
* [[Purging trace and dump files in 11g with adrci]]
 
* [[Rotate alert logs (alertlog) with shell script]]
 
* [[Rotate alert logs (alertlog) with shell script]]
* [Patching]
+
* [[Patching]]
 +
 
 +
===Rotate the listener logs===
 +
Get hold of the listener log files using a method that should be usable for all versions from 9i. This can then be fed into the rotate script.
 +
<pre>
 +
#!/usr/bin/ksh
 +
 
 +
ps -ef | grep tnslsnr | grep inherit | grep -v grep | while read -r psline
 +
do
 +
    listener_name=$(echo ${psline} | awk '{print $(NF-1)}')
 +
    listener_process=$(echo ${psline} | awk '{print $(NF-2)}')
 +
    ORACLE_HOME="$(echo ${listener_process} | sed -e 's;/bin/tnslsnr;;')"
 +
    export TNS_ADMIN=$(echo ${ORACLE_HOME}/network/admin)
 +
 
 +
    listener_log_file=$(${ORACLE_HOME}/bin/lsnrctl status ${listener_name} | awk '/Listener Log File/ {print $NF}')
 +
    if [[ -r "${listener_log_file}" ]]; then
 +
        echo rotate_listener_log "${listener_log_file}"
 +
    else
 +
        echo "No listener log file found for ${listener_name}, skipping."
 +
    fi
 +
done
 +
</pre>

Latest revision as of 12:48, 31 October 2018

Rotate the listener logs[edit]

Get hold of the listener log files using a method that should be usable for all versions from 9i. This can then be fed into the rotate script.

#!/usr/bin/ksh

ps -ef | grep tnslsnr | grep inherit | grep -v grep | while read -r psline
do
    listener_name=$(echo ${psline} | awk '{print $(NF-1)}')
    listener_process=$(echo ${psline} | awk '{print $(NF-2)}')
    ORACLE_HOME="$(echo ${listener_process} | sed -e 's;/bin/tnslsnr;;')"
    export TNS_ADMIN=$(echo ${ORACLE_HOME}/network/admin)

    listener_log_file=$(${ORACLE_HOME}/bin/lsnrctl status ${listener_name} | awk '/Listener Log File/ {print $NF}')
    if [[ -r "${listener_log_file}" ]]; then
        echo rotate_listener_log "${listener_log_file}"
    else
        echo "No listener log file found for ${listener_name}, skipping."
    fi
done