Skip to content

Instantly share code, notes, and snippets.

@wwwins
Created March 8, 2019 08:51
Show Gist options
  • Save wwwins/9434b751a205df290916c529fc233d90 to your computer and use it in GitHub Desktop.
Save wwwins/9434b751a205df290916c529fc233d90 to your computer and use it in GitHub Desktop.
A simple process pool in shell script
#!/bin/sh
FILENAME="XXX.py"
if [ -z $CORES ]
then
CORES=3
fi
cnt=0
while true; do
cnt=$(ps -aux | grep -v "grep" | grep -c "$FILENAME")
if [ $cnt -lt $CORES ]
then
break
fi
sleep 1
done
python -W ignore XXX.py $1 $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment