-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
check arch.ksh
67 lines (55 loc) · 1.33 KB
/
check arch.ksh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/ksh
funct_check_params()
{
if [ ${NARG} -ne 2 ]; then
echo "Archive Check Failed : Not enough Parameters passed" >> $LOGFILE
exit 1
fi
}
funct_check_logmode()
{
STATUS=`${ORACLE_HOME}/bin/sqlplus -s << EOF
/
SET HEADING OFF
SET FEEDBACK OFF
SET PAUSE OFF
SELECT Log_mode from v\\$database;
exit
EOF`
if [ $STATUS = "NOARCHIVELOG" ]; then
echo "Archive Check Failed : $ORACLE_SID database is in NOARCHIVE LOG MODE" >> $LOGFILE
exit 1
fi
}
funct_gzip_files()
{
for i in `ls $ARCH_DIR/*.arc`
do
PIDS=`$INUSE $i`
if [ $PIDS != 0 ]; then
continue
else
$ZIP $i
fi
done
}
################
# Main Program #
################
# Variable Settings
NARG=$#
ARCH_DIR=$1
LOGFILE='/admin/output/arch_check1.log'
ZIP='/usr/bin/gzip'
INUSE='/etc/fuser'
integer PIDS
# Oracle Environment
ORATAB_LOC=/etc/oratab ; export ORATAB_LOC
ORACLE_SID=$2 ; export ORACLE_SID
ORACLE_HOME=`sed /#/d ${ORATAB_LOC} | grep $ORACLE_SID | awk -F: '{print $2}'` ; export ORACLE_HOME
{
funct_check_params
funct_check_logmode
funct_gzip_files
}
## End of Script