Compare commits
	
		
			2 Commits
		
	
	
		
			fd6c9867f2
			...
			6d1a2e9759
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6d1a2e9759 | |||
| deaa1effd9 | 
							
								
								
									
										75
									
								
								examples/jobs/periodic_sleeper.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										75
									
								
								examples/jobs/periodic_sleeper.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,75 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					# This job script takes a nap for 10 seconds (or paramter $2) every 30 minutes (or paramter $1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# SGE options
 | 
				
			||||||
 | 
					#$ -N PSleeper
 | 
				
			||||||
 | 
					#$ -l scf=1M,mem=100M,h_vmem=100M
 | 
				
			||||||
 | 
					#$ -q normal.q
 | 
				
			||||||
 | 
					#$ -cwd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# process args
 | 
				
			||||||
 | 
					case "$1" in
 | 
				
			||||||
 | 
					    -h)
 | 
				
			||||||
 | 
					        echo "usage: $0 [-h | [-d] [T] [nap]]"
 | 
				
			||||||
 | 
					        echo "periodically take a nap"
 | 
				
			||||||
 | 
					        echo ""
 | 
				
			||||||
 | 
					        echo "-h   print this help and exit"
 | 
				
			||||||
 | 
					        echo "-d   print debug info"
 | 
				
			||||||
 | 
					        echo "T    take a nap every T minutes (default: 30)"
 | 
				
			||||||
 | 
					        echo "nap  take a nap for nap seconds (default: 10)"
 | 
				
			||||||
 | 
					        exit 1
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					    *)
 | 
				
			||||||
 | 
					        debug=0
 | 
				
			||||||
 | 
					        terse="-terse"
 | 
				
			||||||
 | 
					        debug_flag=""
 | 
				
			||||||
 | 
					        do_echo=0
 | 
				
			||||||
 | 
					        T=30
 | 
				
			||||||
 | 
					        nap=10
 | 
				
			||||||
 | 
					        while (( "$#" )); do
 | 
				
			||||||
 | 
					            case "$1" in
 | 
				
			||||||
 | 
					                -d)
 | 
				
			||||||
 | 
					                    debug=1
 | 
				
			||||||
 | 
					                    terse=""
 | 
				
			||||||
 | 
					                    debug_flag="-d"
 | 
				
			||||||
 | 
					                    do_echo=1
 | 
				
			||||||
 | 
					                    ;;
 | 
				
			||||||
 | 
					                *)
 | 
				
			||||||
 | 
					                    T=${1:-30}
 | 
				
			||||||
 | 
					                    nap=${2:-10}
 | 
				
			||||||
 | 
					                    break
 | 
				
			||||||
 | 
					                    ;;
 | 
				
			||||||
 | 
					            esac
 | 
				
			||||||
 | 
					            shift
 | 
				
			||||||
 | 
					        done
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# set other variables
 | 
				
			||||||
 | 
					next=$(date -d "${T} minutes" +%Y%m%d%H%M)
 | 
				
			||||||
 | 
					script=/opt/SGE/examples/jobs/periodic_sleeper.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# output some informations
 | 
				
			||||||
 | 
					if [ ${debug} -eq 1 ]; then
 | 
				
			||||||
 | 
					    echo "T = ${T}, nap=${nap}"
 | 
				
			||||||
 | 
					    echo "next run at ${next} (YYYYMMDDhhmm)"
 | 
				
			||||||
 | 
					    echo "debug_flag = ${debug_flag}, do_echo = ${do_echo}"
 | 
				
			||||||
 | 
					    echo ""
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# commands to run in Grid Engine
 | 
				
			||||||
 | 
					/opt/SGE/examples/jobs/sleeper.sh ${nap} ${do_echo}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# re-submit script to execute in T minutes
 | 
				
			||||||
 | 
					jobid=$(qsub ${terse} -a ${next} ${script} ${debug_flag} ${T} ${nap})
 | 
				
			||||||
 | 
					exit_code=$?
 | 
				
			||||||
 | 
					if [ ${debug} -eq 1 ]; then
 | 
				
			||||||
 | 
					    echo "${jobid}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					if [ ${exit_code} -ne 0 ]; then
 | 
				
			||||||
 | 
					    if [ ${debug} -eq 1 ]; then
 | 
				
			||||||
 | 
					        echo "${jobid}"
 | 
				
			||||||
 | 
					        echo "Ups, something went wrong, check output!"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    exit ${exit_code}
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
@ -35,7 +35,7 @@ function clean_up() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### get requested number of GPU's
 | 
					### get requested number of GPU's
 | 
				
			||||||
# use hard resource list first
 | 
					# use hard resource list first
 | 
				
			||||||
NGPUS=$(qstat -j ${JOB_ID} | sed -n "s/hard resource_list:.*gpu=\([[:digit:]]\+\).*/\1/p")
 | 
					NGPUS=$(qstat -j ${JOB_ID} 2>/dev/null | sed -n "s/hard resource_list:.*gpu=\([[:digit:]]\+\).*/\1/p")
 | 
				
			||||||
# set NGPUS to zero if empty
 | 
					# set NGPUS to zero if empty
 | 
				
			||||||
if [ -z "${NGPUS}" ] ; then
 | 
					if [ -z "${NGPUS}" ] ; then
 | 
				
			||||||
    NGPUS=0
 | 
					    NGPUS=0
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user