Shell
Script - Menentukan DUMP level
Assalamualaikum dan salam sejahtera,
Shell script ini digunakan untuk
menentukan tahap atau level backup yang perlu digunakan oleh "dump" atau
"vxdump".
Ia telah dicuba untuk Linux
dan HP-UX. Bagi pengguna Linux Malaysia yang mungkin gunakan LOCALE=ms pastikan
hari ditukarkan kepada hari bahasa melayu.
Script ini juga telah dicuba
untuk korn shell dan sh shell.
Anda boleh bincangkan script
ini di http://www.bincang.net/ dan
http://www.ittutor.net/ bahagian informasi
teknologi.
Wassalam.
Harisfazillah Jamel
2 Dis 2002
Di Internet https://linuxmalaysia.tripod.com/scripts/dumplevel.html
#--- Start Of script
#!/bin/bash
#
# Test under korn shell ksh
# and bash shell and maybe sh
# Please change.
#
# Example script to
# prepare the dump level
# This script by Harisfazillah Bin Jamel
# 02 Dis 2002
#
# This is GPL script
# General Public License http://www.gnu.org/copyleft/gpl.html
#
# http://harisfazillah.cjb.net/
# http://harisfazillah.tripod.com/
#
DATAFILE=/home/ps1411991/script/select.sh
#
if test ! -f $DATAFILE
then
echo "Datafile $DATAFILE not there"
echo "please create"
exit
fi
#
today=`date '+%a'`
startdump=`cat $DATAFILE | grep -n STARTDUMP | cut -f 1 -d : | tail -1`
enddump=`cat $DATAFILE | grep -n ENDDUMP | cut -f 1 -d : | tail -1`
enddump=`expr $enddump - 1`
echo "Today is $today. Data start at line $startdump Data end at line
$enddump"
#
while [ $startdump -lt $enddump ]
do
startdump=`expr $startdump + 1`
WHATDAY=`head -$startdump $DATAFILE | tail -1 | awk '{print
$1}'`
DUMPL=`head -$startdump $DATAFILE | tail -1 | awk '{print
$2}'`
echo "Get from datafile day = $WHATDAY and level is $DUMPL"
if [ $today = $WHATDAY ]
then
DUMPLEVEL=$DUMPL
echo "DUMP Level set to $DUMPLEVEL"
break
else
DUMPLEVEL=0
echo "DUMP level not define set to level
$DUMPLEVEL"
fi
done
#
echo "At last level set at $DUMPLEVEL"
exit
#
# Data area
# It must between STARTDUMP
# and ENDDUMP
# in this example 2 fields only
#
STARTDUMP
Mon 3
Tue 2
Wed 5
Thu 4
Fri 7
Sat 6
Sun 0
ENDDUMP
# --- End of script
[ home ]