#!/bin/sh # Standard job for transferring directories between systems of the same type # on the NOAA/NWS/NCEP Weather and Climate Operational Supercomputer Systems. # The following environment variables will be used by the job if set: # # HOMEtransfers, DATA, COMROOT, RUN, SENDCOM, SENDECF, KEEPDATA, # # # # The "P" progress meter is not entirely reliable since it is based on the number # of files rsync is currently aware of. Because rsync scans directories in an # incrementally recursive fashion, this is not necessarily the total number # of files that need to be sync'd. For instance, it may discover some large files # in a deeply nested directory later on which may skew the progress calculation. # # * RSYNC_DIRECTION, PACKAGE, and CPUS can be set as ecFlow variables date export PS4=' $SECONDS + ' set -x export DATA=${DATA:-${DATAROOT:?}/${jobid:?}} mkdir -p $DATA cd $DATA export jlogfile=${jlogfile:-${DATA}/jlogfile.${jobid}} export cycle=${cycle:-t${cyc}z} setpdy.sh 10 1 . ./PDY export MONCUR=${PDY:0:6} export MONPREV=$(date -d "$PDY -1 month" +%Y%m) export MONNEXT=$(date -d "$PDY +1 month -3 day" +%Y%m) export YEARCUR=${PDY:0:4} export YEARPREV=$(date -d "$PDY -1 year" +%Y) export YEARNEXT=$(date -d "$PDY +16 day" +%Y) export SENDCOM=${SENDCOM:-NO} export SENDECF=${SENDECF:-YES} export SENDWEB=${SENDWEB:-YES} export PARMtransfers=${HOMEtransfers:?}/parm export FIXtransfers=${HOMEtransfers:?}/fix export USHtransfers=${HOMEtransfers:?}/ush # Establish rsync timeout and retry limits export RSYNC_MAX_SECONDS=${RSYNC_MAX_SECONDS:-300} export RSYNC_MAX_ATTEMPTS=${RSYNC_MAX_ATTEMPTS:-3} # Determine which direction to move the data (PUSH or PULL) export RSYNC_DIRECTION=${RSYNC_DIRECTION:-PUSH} # Determine which directories/files to transfer #export TRANSFER_LIST=${TRANSFER_LIST:-$PARMtransfers/transfer_${RUN:?}.list} ecfID=$(echo ${PBS_JOBID} | awk -F"." '{print $1}') export OUTPUTFILE=${PBS_OUTPUTFILE:-${PBS_O_WORKDIR}/${PBS_JOBNAME}.o${ecfID}} export stdout_file=$(readlink -m $OUTPUTFILE) export webserver="nwprod@ncointra" if [ "$envir" = "prod" ]; then export sqlite_database=${sqlite_database:-"/home/nco/www/htdocs/idsb/transfers_wcoss/transfers_wcoss_status.db"} else export sqlite_database=${sqlite_database:-"/home/nco/www/htdocs/idsb/transfers_wcoss_test/transfers_wcoss_status.db"} fi export CLEAN_CHECK_PAGE=${CLEAN_CHECK_PAGE:-YES} export DATES=${DATES:-""} export DAYS=${DAYS:-"1"} ############################################################# # execute the ush script, setup_transfers_catchup.py echo "DATES=$DATES" echo "DAYS=$DAYS" if [ $DAYS -gt 0 ] || ["$DATES" != ""] ; then if [[ "$DATES" != "" ]]; then ${HOMEtransfers}/ush/setup_transfers_catchup.py -e $envir -f $DATES > OUTPUT.${jobid} 2>&1 else ${HOMEtransfers}/ush/setup_transfers_catchup.py -e $envir -f -d $DAYS > OUTPUT.${jobid} 2>&1 fi else echo "DAYS=$DAYS need to be >= 1 or DATES=$DATES need to be some YYYYMMDD. Please check. Exiting" err=99 fi export err=$?; ecflow_client --label info "`cat OUTPUT.${jobid}`" err_chk; ############################################################# echo " Clear the DAYS and DATES ecflow varaibles ...." echo " " >> OUTPUT.${jobid} echo " Clear the DAYS and DATES ecflow varaibles for next run" >> OUTPUT.${jobid} ecflow_client --label info "`cat OUTPUT.${jobid}`" sleep 3 ecflow_client --alter change variable DATES "" $ECF_NAME ecflow_client --alter change variable DAYS "1" $ECF_NAME ############################################################# if [ $CLEAN_CHECK_PAGE = "YES" ]; then echo "CLEAN_CHECK_PAGE=$CLEAN_CHECK_PAGE, Cleaning up the $sqlite_database ..." echo "saving $sqlite_database to ${sqlite_database}.bkup.$PDY" ssh ${webserver:?} "mv $sqlite_database ${sqlite_database}.bkup.$PDY" ssh ${webserver:?} "cp ${sqlite_database}.clean ${sqlite_database}" echo " " >> OUTPUT.${jobid} echo "Cleaning up the $sqlite_database " >> OUTPUT.${jobid} ecflow_client --label info "`cat OUTPUT.${jobid}`" else echo "CLEAN_CHECK_PAGE=$CLEAN_CHECK_PAGE, NOT cleaning up the $sqlite_database ..." echo " " >> OUTPUT.${jobid} echo "CLEAN_CHECK_PAGE=$CLEAN_CHECK_PAGE, NOT cleaning up the $sqlite_database" >> OUTPUT.${jobid} ecflow_client --label info "`cat OUTPUT.${jobid}`" fi ############################################################# postmsg "$jlogfile" "$0 completed normally" ######################################## # Remove the Temporary working directory ######################################## if [[ $KEEPDATA != "YES" ]]; then rm -rf $DATA fi date