複数のscreenを用意しておいて、マルチスレッドで動かす
ZONE="A" THREAD=10 declare -A ZONES=( ["A"]="192.168.10.11" ["B"]="192.168.11.11" ["C"]="192.168.12.11" ) i=1; while [ $i -le $THREAD ] do N=`printf "%02d" "${i}"` SCREEN_NAME=${ZONE}-${N} LOG="${LOGDIR}/${ZONE}_${N}.log" touch $LOG i=`expr $i + 1` if [ -n "`screen -ls | grep ${SCREEN_NAME}`" ]; then echo "already have session_name. ${SCREEN_NAME}" continue 2 fi screen -R ${SCREEN_NAME} sleep 1 screen -d ${SCREEN_NAME} screen -S ${SCREEN_NAME} -X logfile "${LOG}" sleep 1 screen -S ${SCREEN_NAME} -X log on sleep 1 if [ "$ZONE" == "main" ];then i=`expr $THREAD + 1` else screen -S ${SCREEN_NAME} -X stuff "ssh root@${ZONES[${ZONE}]} " sleep 1 screen -S ${SCREEN_NAME} -X stuff "python3.6 " sleep 1 fi