Advertisement
sergio_educacionit

service-monitor.sh

Dec 21st, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.28 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4.  
  5. while :;do
  6.  
  7.     estado=$(systemctl is-active nginx.service)
  8.  
  9.  
  10.     if [ "$estado" != "active" ];then
  11.  
  12.         echo "$(date) -  Se detuvo el servicio 'nginx', iniciando..."
  13.  
  14.         echo "systemctl start nginx.service"
  15.         systemctl start nginx.service
  16.     fi
  17.  
  18.     sleep 5
  19.  
  20. done
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement