Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #!/bin/bash
  2. macadress="XX:XX:XX:XX:XX:XX"
  3. ip="XXX.XXX.XXX.XXX"
  4. logfile="/var/log/nginx/site_access.log"
  5.  
  6. tail -n1 -F $logfile | while read line
  7. do
  8. user=$(echo $line | cut -d " " -f3)
  9. scode=$(echo $line | cut -d " " -f9)
  10.  
  11. if [ $user != "-" ] && [ $scode != "401" ]
  12. then
  13. echo "Ping Server"
  14. ping -c 1 -w 1 -q $ip >/dev/null
  15. status=$?
  16. if [ $status -ne 0 ]
  17. then
  18. echo "Wake Server"
  19. /usr/sbin/etherwake -i enp3s0 "$macadress"
  20.  
  21. fi
  22. fi
  23. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement