Introduction:
This bash script monitors the status of your web server (Apache or Nginx) to ensure it is running correctly. It checks the service status and reports any issues.
Instructions:
For monitoring your server, execute the following commands:
Example Output:
This bash script monitors the status of your web server (Apache or Nginx) to ensure it is running correctly. It checks the service status and reports any issues.
Bash:
#!/bin/bash
# Service name: change to apache2 or nginx as needed
SERVICE="nginx"
status=$(systemctl is-active $SERVICE)
if [ "$status" == "active" ]; then
echo "$SERVICE is running normally."
else
echo "$SERVICE is not active. Please check the service."
fi
Instructions:
For monitoring your server, execute the following commands:
Code:
chmod +x server_monitor.sh
./server_monitor.sh
Example Output:
Code:
nginx is running normally.