Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- trap '\
- echo; \
- echo "The following machines were in the middle of running a task."
- for i in ${!ARRAYNAME[@]}; do \
- machine=${ARRAYNAME[$i]}
- echo "PID: $i Machine: ${ARRAYNAME[$i]}"; \
- kill -9 $i; \
- done; \
- echo "You may need to manually run the desired task on these machines."; \
- exit' SIGHUP SIGINT SIGTERM
- declare -a ARRAYNAME
- for i in `seq 10 20`; do
- sleep 20 &
- ARRAYNAME[$!]="machine-$i"
- done
- wait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement