sh script: 控制文件調用 nohup 命令

# parameter:
# delta: DeltaFile.sh
# full: FullFile.sh
# cir: CIRDataLoad.sh
# reminder: EmailReminder.sh
LOG_DIR="/var/log/wls/"
# Set Log File
LOG_FILE_NAME=".log"
MM=`date +%m`
DD=`date +%d`
HH=`date +%H`
MIN=`date +%M`
YEAR=`date +%Y`
TIMESTAMP=${MM}${DD}${HH}${MIN}
#LOG_FILE="$LOG_DIR/${LOG_FILE_NAME}.${TIMESTAMP}"
LOG_FILE=./log
if [ "$#" -ne 1 ]
then
echo "error: there should have one and only one parameter: delta, full, cir or reminder"
exit 1
fi
shtype=$1
# delta: DeltaFile.sh
# full: FullFile.sh
# cir: CIRDataLoad.sh
# mail: EmailReminder.sh
if [ "${shtype}" = delta ]
then
echo "Starting DeltaFile.sh at `date`">>$LOG_FILE
nohup sh DeltaFile.sh>>$LOG_FILE 2>>$LOG_FILE&
return_code=$?
if [ "${return_code}" -ne 0 ]
then
echo "Finished DeltaFile.sh at `date` , execute failed" >> $LOG_FILE
else
echo "Finished DeltaFile.sh at `date`" >> $LOG_FILE
fi
elif [ "${shtype}" = full ]
then
echo "Starting FullFile.sh at `date`">> $LOG_FILE
nohup sh FullFile.sh>> $LOG_FILE 2>>$LOG_FILE&
return_code=$?
if [ "${return_code}" -ne 0 ]
then
echo "Finished FullFile.sh at `date` , execute failed" >> $LOG_FILE
else
echo "Finished FullFile.sh at `date`" >> $LOG_FILE
fi
elif [ "${shtype}" = cir ]
then
echo "Starting CIRDataLoad.sh at `date`">> $LOG_FILE
nohup sh CIRDataLoad.sh>> $LOG_FILE 2>>$LOG_FILE&
return_code=$?
if [ "${return_code}" -ne 0 ]
then
echo "Finished CIRDataLoad.sh at `date` , execute failed" >> $LOG_FILE
else
echo "Finished CIRDataLoad.sh at `date`" >> $LOG_FILE
fi
elif [ "${shtype}" = reminder ]
then
echo "Starting EmailReminder.sh at `date`">> $LOG_FILE
nohup sh EmailReminder.sh>> $LOG_FILE 2>>$LOG_FILE&
return_code=$?
if [ "${return_code}" -ne 0 ]
then
echo "Finished EmailReminder.sh at `date` , execute failed" >> $LOG_FILE
else
echo "Finished EmailReminder.sh at `date`" >> $LOG_FILE
fi
fi
exit ${return_code}
#end of script

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章