kubernetes case studies

if you are looking for kubernetes case studies.

https://kubernetes.io/case-studies/

 

Run shell script in parallel using runParallell.py

vi runParallell.py

#!/bin/env python
#Run shell scripts in parallel
#using pythong multiprocessing module
# Raju Konduru

import multiprocessing
import time
import os
import sys
import subprocess
from pprint import pprint

if len(sys.argv) == 4:
scriptToRun = sys.argv[1]
inputFile = sys.argv[2]
numOfProcess = int(sys.argv[3])
print type(numOfProcess)
else:
print “Need 2 arguments 1st one input file 2nd one number of concurrent jobs”
print “Example sys.argv[0] myinput.csv 2”

inFile = open(inputFile,’r’)

def mp_worker(GRP):
print “Processs script”+scriptToRun+’ ‘+GRP
subprocess.call(scriptToRun,GRP)

def mp_handler():
p = multiprocessing.Pool(numOfProcess)
with open(inputFile,’r’) as source_file:
results = p.map(mp_worker, source_file,numOfProcess)
print results

if __name__ == ‘__main__’:
mp_handler()

 

Usage:

./runParallell.py $SCRIPT_FILE $INPUT_FILE $NUM_OF_PARALLEL_PROCESS