目标,LINUX下各功能帐户的.profile,start执行程序与相关SQL解析。
数据库备份与整个系统的工作流程。
附:start-777
########################################################################
# start #
########################################################################
# Start shell script for the nightrun. #
# #
# Usage: start ... options ... #
# #
# Execute: 'start options' to get possible options. #
# #
# Author: Martin P. van der Ree (RAET Integratie Services Utrecht) #
# Version: 1.0 april 1991 #
# start V1.0 (04/91) #
# start V1.1 (04/95) #
# @(#) start V1.2 (08/95)
# stgorl80 renamed to stgorl85 #
########################################################################
# @(#) Copyright BSystem International AG, Aspermontstrasse 24, 7006 CHUR, Switzerland.
########################################################################
if [ ${DEBUG:=0} = 1 ]
then
set -x
fi
cd $MS_SHELL
########################################################################
# Check startup parameters:
# Possible parameters are:
# DATE=<YYYYMMDD>
# If specified then no questions are asked, the nightrun
# just starts. Questions are answered with Y(es).
#
# Normally a week, month and year run is executed at the last working
# day of a week, month or year. With the next options these values can
# be overruled:
# DAY=<0|1>
# 0: do not execute day run
# 1: execute day run
# WEEK=<0|1>
# 0: do not execute week run
# 1: execute week run
# MONTH=<0|1>
# 0: do not execute month run
# 1: execute month run
# YEAR=<0|1>
# 0: do not execute year run
# 1: execute year run
#
if [ $# = 1 -a `expr ${1:-a} : 'o*'` != 0 ]
then
tput clear
if [ -r options.doc ]
then
cat options.doc
else
echo File /'options.doc/' with option information not found.
fi
sleep 5
exit 0
fi
tput clear
echo '********** NIGHTRUN STORE **********'
NOASK=0
FNDDAY=0
FNDWEEK=0
FNDMONTH=0
FNDYEAR=0
while [ $# != 0 ]
do
OPT=`echo $1 | tr /[a-z/] /[A-Z/]`
case $OPT in
DATE=* ) NOASK=1
RUNDATE=`expr $OPT : 'DATE=*/(.*/)'`
if [ `isadate $RUNDATE` = 0 ]
then
echo $0: specified date is not in format YYYYMMDD
sleep 5
exit 1
fi
;;
DAY=[01] ) FNDDAY=1
OPTDAY=`expr $OPT : 'DAY=*/(.*/)'`
;;
WEEK=[01] ) FNDWEEK=1
OPTWEEK=`expr $OPT : 'WEEK=*/(.*/)'`
;;
MONTH=[01] ) FNDMONTH=1
OPTMONTH=`expr $OPT : 'MONTH=*/(.*/)'`
;;
YEAR=[01] ) FNDYEAR=1
OPTYEAR=`expr $OPT : 'YEAR=*/(.*/)'`
;;
* ) echo $0: bad option /( $OPT /) specified
sleep 5
exit 1
;;
esac
shift
done
# options checked, go on with nightrun
export NOASK RUNDATE
export FNDDAY FNDWEEK FNDMONTH FNDYEAR
export OPTDAY OPTWEEK OPTMONTH OPTYEAR
########################################################################
if [ -r read.me ]
then
cat read.me
else
echo
fi
echo Create variables ...
. set_environ
echo ' ... done.'
echo Check login name ... //c
if [ "$LOGNAME" != $NRUSER1 -a "$LOGNAME" != ${NRUSER2:-t} ]
then
echo; echo
if [ "$NRUSER2" = "" ]
then
echo User /'$NRUSER1/' must start the nightrun.
else
echo User /'$NRUSER1/' or /'$NRUSER2/' must start the nightrun.
fi
echo
echo '********** NOT STARTED **********'
sleep 5
exit 2
fi
echo done.
echo Check number of times logged in ... //c
# the nightrun user may only be logged in once
if [ "$LOGNAME" = $NRUSER1 ]
then
CNT=`count_user $NRUSER1`
if [ $CNT != 1 ]
then
echo; echo
if [ $CNT = 0 ]
then
echo Do not use /'su/', use login.
else
echo User /'$NRUSER1/' is logged on more than once.
fi
echo
echo '********** NOT STARTED **********'
sleep 5
exit 3
fi
fi
if [ "$LOGNAME" = $NRUSER2 ]
then
CNT=`count_user $NRUSER2`
if [ $CNT != 1 ]
then
echo; echo
if [ $CNT = 0 ]
then
echo Do not use /'su/', use login.
else
echo User /'$NRUSER2/' is logged on more than once.
fi
echo
echo '********** NOT STARTED **********'
sleep 5
exit 3
fi
fi
#if [ "$LOGNAME" = ${NRUSER2:-t} -a `count_user ${NRUSER2:-t}` != 1 ]
#then
# echo; echo
# echo User /'$NRUSER2/' is logged on more than once.
# echo
# echo '********** NOT STARTED **********'
# sleep 5
# exit 4
#fi
echo done.
echo Check if background processes are not running
# background processes:
# 1. stinvp80: apply corrections
# not allowed to kill
# 2. stinv100: processing inventory countings
# can be killed with program stinv110
# 3. sttilp10: processing invoices
# can be 'killed' with do_sttilp10
# 4. stgorl85: printing tickets
# can be killed with program stzebra option stop.
echo Check stinvp80 ... //c
if [ `ps -ae | grep -c stinvp80` != 0 ]
then
echo; echo
echo Background process /'stinvp80/' is running, wait till finished.
echo
echo '********** NOT STARTED **********'
sleep 5
exit 5
fi
echo
echo Check stinv100 ... //c
if [ `ps -ae | grep -c stinv100` != 0 ]
then
echo; echo
while true
do
echo Background process /'stinv100/' is running, 'K(ill) or E(xit)' //c
if [ $NOASK = 0 ]
then
read ANSWER
else
ANSWER=E
fi
if [ ${ANSWER:-t} = 'K' -o ${ANSWER:-t} = 'k' -o /
${ANSWER:-t} = 'E' -o ${ANSWER:-t} = 'e' ]
then
break;
fi
done
if [ $ANSWER = 'E' -o $ANSWER = 'e' ]
then
echo
echo '********** NOT STARTED **********'
sleep 5
exit 5
else # $ANSWER = 'K' -o $ANSWER = 'k'
echo
$MS_PROGS/stinv110
echo
fi
fi
echo
echo Check sttilp10 ... //c
while [ `ps -ae | grep -c sttilp10` != 0 ]
do
NOWAIT=1; export NOWAIT
# Now do_tilp10 is not asking for an extra return
echo; echo
ACTIVE_TILLS=`$MS_PROGS/st_topen $ORAID $RUNDATE`
echo Background process /'sttilp10/' is running, $ACTIVE_TILLS are open
echo 'E(xit), S(top)' //c
if [ $NOASK = 0 ]
then
read ANSWER
else
ANSWER=E
fi
if [ ${ANSWER:-t} = 'E' -o ${ANSWER:-t} = 'e' ]
then
echo
echo '********** NOT STARTED **********'
sleep 5
exit 5
elif [ $ANSWER = 'S' -o $ANSWER = 's' ]
then
echo
$MS_PROGS/do_tilp10 $ORAID stop
echo Wait 240 seconds... //c
sleep 240
echo
fi
done
echo
echo Check stgorl85 ... //c
if [ `ps -ae | grep -c stgorl85` != 0 ]
then
echo; echo
while true
do
echo Background process /'stgorl85/' is running, 'K(ill) or E(xit)' //c
if [ $NOASK = 0 ]
then
read ANSWER
else
ANSWER=K
fi
if [ ${ANSWER:-t} = 'K' -o ${ANSWER:-t} = 'k' -o /
${ANSWER:-t} = 'E' -o ${ANSWER:-t} = 'e' ]
then
break;
fi
done
if [ $ANSWER = 'E' -o $ANSWER = 'e' ]
then
echo
echo '********** NOT STARTED **********'
sleep 5
exit 5
else # $ANSWER = 'K' -o $ANSWER = 'k'
echo
$MS_PROGS/stzebra $ORAID $RUNDATE stop
echo
fi
fi
echo
echo done.
echo Check if nightrun is not running at the moment... //c
# 5 processes: login sh, this program sh, [ ], ps and wc
# For safety everything is ok if nbr of processes is less than or equal
# to 5. If 5 is incorrect change it. (This depends on how the terminal
# connected to the computer, via rlogin or via normal terminal.)
sleep 2 # to end <defunct> processes
if [ `ps -u$LOGNAME | wc -l` -gt 7 ]
then
echo
echo There are more processes running for $LOGNAME than only this program
echo
echo '********** NOT STARTED **********'
sleep 5
exit 6
fi
echo done.
echo Check if nightrun is already finished ... //c
if [ `grep -c stnightend $RESTARTLOG` != 0 ]
then
echo; echo
echo NIGHT RUN is already finished for this run date.
echo 'Press <return> to Exit' //c
read ANSWER
echo
echo '********** NOT STARTED **********'
sleep 5
exit 7
fi
echo done.
RESTART=0
echo Check if nightrun is already started ... //c
if [ `grep -c stnightstart $RESTARTLOG` != 0 ]
then
echo; echo
echo NIGHT RUN is already started for this run date.
echo
RESTART=1
while true
do
echo 'Execute a restart (Y(es) / E(xit)):' //c
if [ $NOASK = 0 ]
then
read ANSWER
else
ANSWER=Y
fi
if [ ${ANSWER:-t} = 'Y' -o ${ANSWER:-t} = 'y' -o /
${ANSWER:-t} = 'E' -o ${ANSWER:-t} = 'e' ]
then
break;
fi
done
if [ $ANSWER = 'E' -o $ANSWER = 'e' ]
then
echo
echo '********** NOT STARTED **********'
sleep 5
exit 7
fi
echo
fi
echo done.
echo Extra check on start date nightrun ... //c
if [ $RESTART = 0 -a `$MS_PROGS/stngtp99 $ORAID $RUNDATE 0` = 0 ]
then
while true
do
echo
echo The date /'$RUNDATE/' is not the next working day since the
echo previous executed nightrun.
echo 'Continue: (Y(es) / E(xit)):' //c
if [ $NOASK = 0 ]
then
read ANSWER
else
ANSWER=Y
fi
if [ ${ANSWER:-t} = 'Y' -o ${ANSWER:-t} = 'y' -o /
${ANSWER:-t} = 'E' -o ${ANSWER:-t} = 'e' ]
then
break;
fi
done
if [ $ANSWER = 'E' -o $ANSWER = 'e' ]
then
echo
echo '********** NOT STARTED **********'
sleep 5
exit 8
fi
echo
fi
echo done.
echo Check if there are users working ... //c
/bin/rm -f $MS_NIGHTRUN
LOGGED_IN=`$MS_PROGS/st_user $ORAID $RUNDATE $LOGNAME`
export LOGGED_IN
ANSWER=''
if [ -n "$LOGGED_IN" ]
then
echo
echo There are some users working in the bsys application,
echo the users: $LOGGED_IN are working
while true
do
echo 'Notify and kill those users? (Y(es) / E(xit)):' //c
if [ $NOASK = 0 ]
then
read ANSWER
else
ANSWER=Y
fi
if [ ${ANSWER:-t} = 'Y' -o ${ANSWER:-t} = 'y' -o /
${ANSWER:-t} = 'E' -o ${ANSWER:-t} = 'e' ]
then
break;
fi
done
if [ $ANSWER = 'E' -o $ANSWER = 'e' ]
then
echo
/bin/rm -f $MS_NIGHTRUN
echo '********** NOT STARTED **********'
sleep 5
exit 8
fi
else
echo not one found ...
fi
echo ' ... done.'
NOASK=0
while true
do
echo Start background process invoice processing /(sttilp10/) after nightrun/?
echo 'Y(es) or N(o):' //c
if [ $NOASK = 0 ]
then
read ANSWER
else
ANSWER=N
fi
if [ ${ANSWER:-t} = 'Y' -o ${ANSWER:-t} = 'y' -o /
${ANSWER:-t} = 'N' -o ${ANSWER:-t} = 'n' ]
then
break;
fi
done
if [ $ANSWER = 'Y' -o $ANSWER = 'y' ]
then
START_STTILP10=1; export START_STTILP10
else
START_STTILP10=0; export START_STTILP10
fi
echo $START_STTILP10
echo Start nightrun ... //c
nohup stnight >>$LOGDIR/stnight1.$JULIAN 2>>$LOGDIR/stnight2.$JULIAN &
echo done.
echo
echo '********** IS RUNNING **********'
echo 'See the directory' /'$LISTDIR/' for listings and
echo ' the directory' /'$LOGDIR/' for logging information
echo
sleep 5