SGE scripts examples

The NICA LHEP offline cluster

Simple.sh

#!/bin/sh
# This is a simple example of a SGE batch script
# request Bourne shell as shell for job
#$ -S /bin/sh
#
# print date and time
date
# Sleep for 20 seconds
sleep 20
# print date and time again
date

Advanced.sh

#!/bin/bash
# request Bourne shell as shell for job
#$ -S /bin/bash
#$ -wd /weekly/$USER/MC/TMP
#$ -cwd
#$ -N mc-bat
#$ -j y
#$ -l h=(ncx20[5-8]|ncx21[1-8]|ncx22[5-8]|ncx23[1-8])
#$ -t 1-400
#$ -o /weekly/$USER/MC/TMP
## $ -e /weekly/$USER/MC/TMP
#
#Main directory
export MAIN_DIR=/weekly/${USER}/MC
# sleep $[ ( $RANDOM % 100 )  + 1 ]s
export MACRO_DIR=$MAIN_DIR/macro
export BUILD_DIR=$MAIN_DIR/build
export OUT=$MAIN_DIR/batching
if [ -f "${OUT}/MC_bin${SGE_TASK_ID}.root" ]; then
  exit 0
fi
. ${BUILD_DIR}/settings.sh
mkdir $MAIN_DIR/d_${JOB_ID}_${SGE_TASK_ID}
cd $MAIN_DIR/d_${JOB_ID}_${SGE_TASK_ID} 
#cp ${MACRO_DIR}/runMC.C runMC.C
#export INFILE=/nica/mpd22/kireev/CORRELATIONS/part01/AuAu-b03/SRT_8.8/phsd_bin${SGE_TASK_ID}.dat.gz
export OUTFILE=${OUT}/MC_bin${SGE_TASK_ID}.root
# sed -e "s|INPUTFILE|${INFILE}|" -i runMC.C
# sed -e "s|OUTPUTFILE|${OUTFILE}|" -i runMC.C
# root -b -q runMC.C | tee >> $OUT/JOB_${JOB_ID}_${SGE_TASK_ID}.log 
# cd ..
# rm -rf d_${JOB_ID}_${SGE_TASK_ID}
date