Databases Reference
In-Depth Information
The previous command replaces the contents of the
listener.log
file with the contents of /
dev/null
(a default
file on Linux/Unix systems that contains nothing). The result of this command is that the
listener.log
file is
truncated, and the listener can continue to actively write to it.
Listed next is a shell script that truncates the default
listener.log
file. This script is dependent on setting the OS
variable
ORACLE_BASE
. If you don't set that variable in your environment, you'll have to hard-code the directory path
within this script:
#!/bin/bash
#
if [ $# -ne 1 ]; then
echo "Usage: $0 SID"
exit 1
fi
# See chapter 2 for details on setting OS variables
# Source oracle OS variables with oraset script
. /etc/oraset $1
#
MAILX='/bin/mailx'
MAIL_LIST='
dkuhn@gmail.com
'
BOX=$(uname -a | awk '{print $2}' | cut -f 1 -d'.')
#
if [ -f $ORACLE_BASE/diag/tnslsnr/$BOX/listener/trace/listener.log ]; then
cat /dev/null > $ORACLE_BASE/diag/tnslsnr/$BOX/listener/trace/listener.log
fi
if [ $? -ne 0 ]; then
echo "trunc list. problem" | $MAILX -s "trunc list. problem $1" $MAIL_LIST
else
echo "no problem..."
fi
exit 0
The following
cron
entry runs the prior script on a monthly basis (this entry should all be on one line but has
been placed on two lines in order to fit on the page):
30 6 1 * * /orahome/oracle/bin/trunc_log.bsh DWREP
1>/orahome/oracle/bin/log/trunc_log.log 2>&1
Checking for Locked Production Accounts
Usually I have a database profile in place that specifies that a database account become locked after a designated
number of failed login attempts. For example, I'll set the
DEFAULT
profile
FAILED_LOGIN_ATTEMPTS
to 5. Sometimes,
however, a rogue user or developer will attempt to guess the production account password, and after five attempts,
locks the production account. When this happens, I need to know about it as soon as possible so that I can investigate
the issue and then unlock the account.
The following shell script checks the
LOCK_DATE
value in
DBA_USERS
for a list of production database accounts:
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 SID"
exit 1