Lowercase on the fly transform
This piece of code transforms the variable as its printed to lowercase print $ORACLE_SID|tr ‘[A-Z]’ ‘[a-z]’
.kshrc and .bashrc for persistent settings
In order to get set -o vi This should be set at the .kshrc or .bashrc level [code language=”sql”] # M Culp # .kshrc # Source global definitions if [ -f /etc/kshrc ]; then . /etc/kshrc fi # use emacs editing mode by default # set -o emacs set -o vi # User specific aliases […]
Korn shell file eval code
[code language=”sql”] check_sys_pass() { ###################################################### # This will read a .file for the system password # or prompt for a password ###################################################### export PWFILE=.syspasswd if [ ! -f $PWFILE ]; then echo "Please enter the SYS password on the primary database: $PRIMARY_DB on $PRIMARY_HOST :"; read sys_pass else sys_pass=$(cat $PWFILE |head -1) fi } [/code]
longops.sql
[code language=”sql”] — ———————————————————————————– — File Name : https://oracle-base.com/dba/monitoring/longops.sql — Author : Tim Hall — Description : Displays information on all long operations. — Requirements : Access to the V$ views. — Call Syntax : @longops — Last Modified: 03/07/2003 — ———————————————————————————– COLUMN sid FORMAT 999 COLUMN serial# FORMAT 9999999 COLUMN machine FORMAT A30 COLUMN […]
TAR Commands
This should go into the Linux_common.ksh library file [code language=”sql”] cr_tar_apex_common() { # Create the tar file tar -cvf /oracle/admin/scripts/mrc/apex_common_09062017.tar /oracle/admin/scripts/apex/*.ksh /oracle/admin/scripts/dba120/apex6 } [/code] tar –help Examples: # Create archive.tar from files foo and bar. tar -cf archive.tar foo bar # List all files in archive.tar verbosely. tar -tvf archive.tar # Extract all files from […]
db_switch function
[code language=”SQL”] function db_switch { ############################################################################### # function switches the database environments for any databases on the cluster # ############################################################################### #cd /var/opt/oracle/admin/scripts #. ./env_generic # export NEW_ORACLE_SID=ASM1+; . ~/.profile > /dev/null echo echo "Check database(s) in OCR" echo ————————————— echo gen_db_lst #srvctl config > dblst #echo #echo "Databases listed in clusterware" #cat dblst #echo export […]
Shell Script Loop
This piece of code sets files equal to 3 different files, then goes through a for / next loop to determine if they exist [code language=”sql”] #!/bin/ksh files="/etc/passwd /etc/group /etc/hosts" for f in $files; do if [ ! -f $f ] then echo "$f file missing!" fi done [/code] [code language=”sql”] #!/bin/ksh for car in […]
Linux Quick Finds
Finding Large Directories look for large files with this command: find . -type f -size +100000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’ This looks for files over 100MB, but other than datafiles there were very few files found. I knew I needed to look for large directories. […]