Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. trap '\
  5. echo; \
  6. echo "The following machines were in the middle of running a task."
  7. for i in ${!ARRAYNAME[@]}; do \
  8. machine=${ARRAYNAME[$i]}
  9. echo "PID: $i Machine: ${ARRAYNAME[$i]}"; \
  10. kill -9 $i; \
  11. done; \
  12. echo "You may need to manually run the desired task on these machines."; \
  13. exit' SIGHUP SIGINT SIGTERM
  14.  
  15. declare -a ARRAYNAME
  16. for i in `seq 10 20`; do
  17. sleep 20 &
  18. ARRAYNAME[$!]="machine-$i"
  19. done
  20.  
  21. wait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement