
Installgen
Features and Benefits
Installgen
Demo Available for download...
Bookmark This Page

#!/bin/bash
# script: /Volumes/u01/server_scripts/rotateoraclefiles.sh
# Features: This shell script runs nightly via CRON job to remove/rotate Oracle files.
#
# Script Sequence#: 13
# ******** Rotate Server logs nightly at 11:55PM ********
# 55 23 * * 0-6 /Volumes/u01/server_scripts/rotateoraclefiles.sh
# Used By: run automatically via CRON
# Copyright 2002 by .com Solutions Inc.
#
# ---------------------- Revision History ---------------
# Date By Changes
# 9-27-2001 dsimpson Initial Release
# 9-30-2001 dsimpson Added use of environment variables for paths
# 10-01-2002 dsimpson Replaced rotation of dbsnmpc.log and dbsnmpw.log
# files with dbsnmp.log files (for Oracle 9i).
# Added rotation of agntsrvc.log file rotation.
# Added stopping of intelligent agent and stopping only the listener
# logging (without stopping the listener itself) during log
# rotations.
# Added rotation of Oracle Agent.nohup file.
# This output file was created by Installgen version 1.38 on Sat Nov 23 07:13:32 2002. By .com Solutions Inc. www.dotcomsolutionsinc.net
# Note: The variables defined below must be used because CRON starts up early
# in the startup process of the system and will not generally have access to
# the environment variables defined in /etc/profile.
PATH=/bin:/sbin:/usr/bin:/usr/sbin:.
ORACLE_BASE=/Users/oracle/v920
ORACLE_HOME=/Users/oracle/v920
ORACLE_OWNER=oracle
ORACLE_OWNER_PATH=/Users/oracle
ORACLE_GROUP=dba
PATH=$PATH:$ORACLE_HOME/bin
SRCHOME=$ORACLE_HOME
ORACLE_SID=prod1
CLASSPATH=$ORACLE_HOME/DBCreate/oradev/classes/orapts.jar:$ORACLE_HOME/jdbc/lib/classes12.zip:$CLASSPATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
DYLD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:$DYLD_LIBRARY_PATH
ORAENV_ASK=NO
TNS_ADMIN=$ORACLE_HOME/network/admin
TERM=vt100
NLS_LANG=AMERICAN_AMERICA.US7ASCII
export PATH ORACLE_BASE ORACLE_HOME SRCHOME ORACLE_SID CLASSPATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH ORACLE_OWNER TNS_ADMIN TERM NLS_LANG
# the following ulimit parameters are required by the Oracle database on Mac OS X
ulimit -c unlimited
ulimit -d unlimited
ulimit -s 65536
ulimit -u 500
ulimit -n 10000
ORA_BACKUP_DIR=/Volumes/backup
ORA_ARCHIVE_DIR=/Volumes/archive
ORA_BDUMP_DIR=/Volumes/u01/bdump
ORA_CDUMP_DIR=/Volumes/u01/cdump
ORA_UDUMP_DIR=/Volumes/u01/udump
export ORA_BACKUP_DIR ORA_ARCHIVE_DIR ORA_BDUMP_DIR ORA_CDUMP_DIR ORA_UDUMP_DIR
# Remove ASET report files after 7 days
#find /usr/aset/reports -mtime +7 -exec rm -R {} \;
# Remove old Oracle backup files in /Volumes/backup directory after 7 days
find $ORA_BACKUP_DIR -mtime +7 -exec rm {} \;
# Remove old Oracle archivelog files in /Volumes/archive directory after 7 days
# There should only be current archivelog files for today if backups are working correctly
find $ORA_ARCHIVE_DIR -mtime +7 -exec rm {} \;
# Remove Oracle bdump,cdump,udump files after 7 days
find $ORA_BDUMP_DIR -mtime +7 -exec rm {} \;
find $ORA_UDUMP_DIR -mtime +7 -exec rm {} \;
find $ORA_CDUMP_DIR -mtime +7 -exec rm -R {} \;
# turn off listener logging while rotating log file
$ORACLE_HOME/bin/lsnrctl set log_status off
# stop the intelligent agent while rotating log file
$ORACLE_HOME/bin/agentctl stop
# Rotate the Oracle listener.log log file nightly
LOG=listener.log
cd $ORACLE_HOME/network/log
test -f $LOG.5 && mv $LOG.5 $LOG.6
test -f $LOG.4 && mv $LOG.4 $LOG.5
test -f $LOG.3 && mv $LOG.3 $LOG.4
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
# Rotate the Oracle dbsnmp.log log file nightly
LOG=dbsnmp.log
cd $ORACLE_HOME/network/log
test -f $LOG.5 && mv $LOG.5 $LOG.6
test -f $LOG.4 && mv $LOG.4 $LOG.5
test -f $LOG.3 && mv $LOG.3 $LOG.4
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
# Rotate the Oracle agntsrvc.log log file nightly
LOG=agntsrvc.log
cd $ORACLE_HOME/network/log
test -f $LOG.5 && mv $LOG.5 $LOG.6
test -f $LOG.4 && mv $LOG.4 $LOG.5
test -f $LOG.3 && mv $LOG.3 $LOG.4
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
# Rotate the Oracle agntsrvc.nohup log file nightly
LOG=agntsrvc.nohup
cd $ORACLE_HOME/network/log
test -f $LOG.5 && mv $LOG.5 $LOG.6
test -f $LOG.4 && mv $LOG.4 $LOG.5
test -f $LOG.3 && mv $LOG.3 $LOG.4
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
# Rotate the Oracle nmiconf.log log file nightly
LOG=nmiconf.log
cd $ORACLE_HOME/network/log
test -f $LOG.5 && mv $LOG.5 $LOG.6
test -f $LOG.4 && mv $LOG.4 $LOG.5
test -f $LOG.3 && mv $LOG.3 $LOG.4
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
# Rotate the Oracle sqlnet.log log file nightly
LOG=sqlnet.log
cd $ORACLE_HOME/network/log
test -f $LOG.5 && mv $LOG.5 $LOG.6
test -f $LOG.4 && mv $LOG.4 $LOG.5
test -f $LOG.3 && mv $LOG.3 $LOG.4
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
# turn on listener logging
$ORACLE_HOME/bin/lsnrctl set log_status on
# re-start intelligent agent
$ORACLE_HOME/bin/agentctl start

