Script for detecting Apache running status under Linux

  

Check if apache is started regularly. If it is not started, start the service automatically #!/bin/shcheck_services(){echo "Check services..."services="" ;if [ -z "`ps -A| Grep httpd`" ]thenservices="$services httpd"fi}start_services(){echo "Start services..."for start_services in `echo $services`do/etc/init.d/$start_services startdoneecho} Check_servicesechoecho "Check services succeed!"echostart_servicesechoecho "Start services succeed!"echo

This script is added to the scheduled task to implement the timing detection service. */1 * * * * root /user/bin/httpcheck.sh

Add the above code to /etc/crontab. After restarting the crond service, you can check the running status of the service every minute.

Copyright © Windows knowledge All Rights Reserved