Created
September 11, 2022 09:47
-
-
Save kerus1024/245d6cc824135ea8b45bf49bd275a9e3 to your computer and use it in GitHub Desktop.
Bash Shell Script Run multiple process with features that re-starts process when single process failed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
JOBS=() | |
run_jobs() { | |
$@ & | |
JOBS+=($!) | |
} | |
while true; | |
do | |
if [ ! -z "${JOBS[@]}" ]; then | |
echo "${JOBS[@]}" | xargs -r kill -9 | |
echo "--------------------------------------" | |
echo -e "\n\n\n\n\nProcess (Re)start\n\n\n\n" | |
echo "--------------------------------------" | |
fi | |
JOBS=() | |
cd /home/kerus1024/datamerge/ | |
run_jobs node app.js | |
cd /home/kerus1024/crawler | |
run_jobs node app.js a | |
run_jobs node app.js b | |
run_jobs node app.js c | |
wait -n ${JOBS[@]} | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment