HOSTNAME=`uname -n`
/usr/sbin/clinfo
CLUSTERACTIVE=$?
# First check whether the Cluster itself is active
if [ $CLUSTERACTIVE != "0" ]
then
echo Cluster is NOT ACTIVE - EXITING
exit 1
fi
# Now check whether we are on the active Cluster Node for this Resource Group
CLUSTERSTATE=`/usr/cluster/bin/scha_resource_get -R ora-db03-lh-rs -O RESOURCE_STATE_NODE $HOSTNAME`
if [ $CLUSTERSTATE != "ONLINE" ]
then
echo "Cluster is NOT ON ACTIVE CLUSTERNODE for this resource group - EXITING"
exit 1
fi
echo "Cluster status check OK"
### Cluster check done
# check whether correct User executes this Script
USERNAME=$LOGNAME
if [ ! $USERNAME = "root" ]
then
echo "WRONG USERNAME, must be User ROOT"
exit 1
fi
echo "User check OK"
### User check done
# Get command Line Parameters
INSTANCE=$1
USR=$2
# Now check whether required Parameter has been given on command Line
if [ ! $# = "2" ]
then
echo
echo "Wrong number of Parameters or no Parameter have been given. USAGE: arc_aging.sh FIN/DIS ocafin1/oracle"
echo
exit 1
else
echo "Parameter count check OK"
fi
# Now check whether valid Parameters have been given
if [ "$INSTANCE" = "FIN" -o "$INSTANCE" = "DIS" ]
then
echo "Parameter validation check OK"
else
echo "Parameter must be FIN or DIS !!"
exit 1
fi
if [ "$USR" = "ocafin1" -o "$USR" = "oracle" ]
then
echo "Parameter validation check OK"
else
echo "Parameter must be oracle or ocafin1 !!"
exit 1
fi
### Parameter check done
# Build local Environment Variables
INSTANCE_REDO=$1_REDO2
## Set the archive Directory
ARCH1="/global/$INSTANCE_REDO/archlogs"
ARCH2="/global/ORA_BACKUP/archlogs/$INSTANCE"
ARCH3="/global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
ARCH4="/global/LOG_REPLICATION/$INSTANCE"
# Delete Archive logs on /global/LOG_REPLICATION/$INSTANCE volume when not accessed since 10 days
# These are the archive logs which where replicated to Euromoda/TIU via SNDR
echo "SNDR: Deleting Archive Logs on /global/LOG_REPLICATION/$INSTANCE older than 10 days ...."
date '+Start: %H:%M:%S'
echo "The following files are going to be deleted:"
su $USR -c "find $ARCH4 -type f -atime +10 -exec ls {} \;"
su $USR -c "find $ARCH4 -type f -atime +10 -exec rm {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
# Delete Archive logs on /global/ORA_BACKUP volume when not accessed since 15 days
echo "Cleaning up Archive Logs on /global/ORA_BACKUP/archlogs/$INSTANCE/compressed older than 15 days ...."
date '+Start: %H:%M:%S'
echo "The following files are going to be deleted:"
su $USR -c "find $ARCH3 -type f -atime +10 -exec ls {} \;"
su $USR -c "find $ARCH3 -type f -atime +10 -exec rm {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
# Compress Archive logs on /global/ORA_BACKUP volume when not accessed since 2 days
echo "Compressing Archive Logs on /global/ORA_BACKUP/archlogs/$INSTANCE older than 2 days ...."
date '+Start: %H:%M:%S'
su $USR -c "find $ARCH2 -name compressed -prune -o -type f -atime +2 -exec ls {} \;"
su $USR -c "find $ARCH2 -name compressed -prune -o -type f -atime +2 -exec compress {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
# Move compressed files to subfolder
echo "Moving compressed files to subfolder ...."
date '+Start: %H:%M:%S'
su $USR -c "mv /global/ORA_BACKUP/archlogs/$INSTANCE/*.Z /global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
su $USR -c "mv /global/ORA_BACKUP/archlogs/$INSTANCE/*.gz /global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
echo Return code: $?
date '+End: %H:%M:%S'
# Move Archive logs from /global/(FIN/DIS)_REDO2/archlogs to the /global/ORA_BACKUP volume when not accessed since 1 day
echo "Moving Archive Logs to /global/ORA_BACKUP/archlogs/$INSTANCE older than 1 day ...."
date '+Start: %H:%M:%S'
su $USR -c "find $ARCH1 -name compressed -prune -o -type f -atime 1 -exec ls {} \;"
su $USR -c "find $ARCH1 -name compressed -prune -o -type f -atime 1 -exec mv {} /global/ORA_BACKUP/archlogs/$INSTANCE/ \;"
echo Return code: $?
date '+End: %H:%M:%S'
echo "Current Disc usage ...."
df -k|grep ORA
df -k|grep $INSTANCE_REDO
Code:
/root/scripts>./ARC-PURGE.sh ESPOS espos 2>&1 mailx -s "ESPOS Archivelog Purge" babu.knb@gmail.com
User check OK
Wrong number of Parameters or no Parameter have been given. USAGE: arc_purge.sh ESPOS/FPRINT espos/fprint
I got below error message. Please advice me what was the problem?
Hi,
I have a shell script in which I am calling a function from a different shell script. This functions executes the SQL and the results are stored in a log file.
If the result of the SQL is "no rows selected" then I need to exit the main shell script. My shell script is executing fine if... (5 Replies)
:confused:
Hi,
I have written a script which calls a stored procrdure. The Stored procedure has 2 inputs and 6 outputs. I need to capture one of the outputs.
But I am not able to get any result from this simple script-
! /bin/ksh
echo "connect to dbau user etlbitst using anf1892;" >... (1 Reply)
hi,,
i have perl scipt with line :
system('./try.sh $t $d $m');
in shell scipt try.sh i have the line:
echo $1
its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
hy,
i have a problem with shell script with sybase. if start single command this script working, but if run into file for example select.sh, the script doesn't create output. Can you help me please ??? thank's
USER=`cat $SYBASE/.asepwd | cut -d: -f2 | head -1`
PWD=`asepwd.sh $USER... (4 Replies)
Hello. I am trying to make this shell script bellow work on my server wich should take the names in newacc.cvs and add them to the system. For each user the script should ask me to enter a password for the user im adding and then add them to the system, however my current solution do not work atm... (7 Replies)
Hello, guys...
I'm new to IBM AIX server admin. Actuall, I administrate Oracle 10g on it.
*SYSTEM INFO
- IBM AIX 6 Powerpc
- Oracle 10g R2 (10.2.0.4.0 - 64bit)
I wrote a script like bellow...
DATE='date'
cp /oracle/product/10g/network/log/listener_temp.log... (4 Replies)
hi every body
this is my first thread in this forum, i hope find a solution for my problem
i have to write a script bt i still have some error and i don't know how to correct them
$ for i in `seq 500 505`; do ./generateur_tache $i tache$i.txt; nprocs=$i; copt$i=`cat tache$i.txt | ./copt.awk` ;... (10 Replies)
Hello,
Ubuntu server 11.10
can anybody help what is problem with my shell script?
#!/bin/bash
#script to find out currently logged on user is root or not.
if ]
then
echo "You are super"
else
echo "You are awesome!"
fi
When I run script, I get following output
./uid: line 3:
I... (4 Replies)