Skip to content

Instantly share code, notes, and snippets.

@nicoulaj
Created June 2, 2016 14:54
Show Gist options
  • Save nicoulaj/91a18d5c0ed952cbd027bae53bbbedbd to your computer and use it in GitHub Desktop.
Save nicoulaj/91a18d5c0ed952cbd027bae53bbbedbd to your computer and use it in GitHub Desktop.
SGE -notify and -inherit
#!/bin/bash
# Trap signals
for signal in HUP INT QUIT ABRT KILL SEGV USR1 USR2 TERM; do
trap "echo 'master : Received signal ${signal}...'" ${signal}
done
# Submit slaves
slave_id=0; while read host slots queue procs; do
for slot in $(seq $slots); do
echo "Launching slave $(( ++slave_id ))..."
qrsh -V \
-inherit \
$host \
${TEST_DIR}/test-slave.sh ${slave_id} \
&
done
done < $PE_HOSTFILE
# Wait for slaves to be started
sleep 5
# Kill own job
qdel $JOB_ID
# Print alive message every second
i=0; while sleep 1; do
echo "master : $(( ++i ))"
done
#!/bin/bash
# Trap signals
for signal in HUP INT QUIT ABRT KILL SEGV USR1 USR2 TERM; do
trap "echo 'slave ${JOB_ID} : Received signal ${signal}...'" ${signal}
done
# Print alive message every second
i=0; while sleep 1; do
echo "slave ${1} : $(( ++i ))"
done
#!/bin/bash
export TEST_QUEUE=test.q
export TEST_PE=test_pe
export TEST_SLAVES=4
export TEST_MEMORY=1G
export TEST_DIR=$PWD
# Launch parallel job
qrsh -V \
-notify \
-now no \
-q "${TEST_QUEUE}@*" \
-pe ${TEST_PE} ${TEST_SLAVES} \
-l s_vmem=${TEST_MEMORY} \
${TEST_DIR}/test-master.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment