Guest User

Untitled

a guest
May 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #!/bin/bash
  2. pid=$1
  3. me="$(basename $0)($$):"
  4. if [ -z "$pid" ]
  5. then
  6. echo "$me a PID is required as an argument" >&2
  7. exit 2
  8. fi
  9.  
  10. name=$(ps -p $pid -o comm=)
  11. if [ $? -eq 0 ]
  12. then
  13. echo "$me waiting for PID $pid to finish ($name)"
  14. while ps -p $pid > /dev/null; do sleep 5; done;
  15. else
  16. echo "$me failed to find process with PID $pid" >&2
  17. exit 1
  18. fi
Add Comment
Please, Sign In to add comment