From 55823096510f4c308f08aaca133e1f7ae335b61b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 9 Apr 2016 18:18:28 +0200 Subject: initial commit: sollte funktionieren --- runjobsparallel | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 runjobsparallel diff --git a/runjobsparallel b/runjobsparallel new file mode 100755 index 0000000..763d301 --- /dev/null +++ b/runjobsparallel @@ -0,0 +1,50 @@ +#!/bin/bash +# +# /usr/sbin/runjobsparallel: run all executables in specified directory parallel +# + +if [ "$1" = "" ]; then + echo "usage: $0 " + exit 1 +fi + +cd $1 || exit 1 + +tmpDir=$(mktemp -d /tmp/runjobsparallel.XXXXXX) + +for file in ./*; do + if [ -f $file ] && [ -x $file ]; then + i=${#errFiles[@]} + errFiles[${i}]="${tmpDir}/err.${i}" + (nice -n 19 $file; echo $? > ${errFiles[${i}]})& + pids[${i}]=$! + fi +done + +allesDa=false +while ! ${allesDa} +do + sleep 1 + allesDa=true + maxErr=0 + for ((i=0; i<${#errFiles[@]}; i++)) + do + if [ -r ${errFiles[${i}]} ] + then + curErr=$(cat "${errFiles[${i}]}") + [ ${curErr} -gt ${maxErr} ] && maxErr=${curErr} + elif ps aux | awk '{print $2}' | grep -q "^${pids[${i}]}\$" + then + allesDa=false + else + echo 255 > "${errFiles[${i}]}" + maxErr=255 + fi + done +done + +rm -rf ${tmpDir} + +exit ${maxErr} + +# End of file -- cgit v1.2.3-70-g09d2