Linux Server Hack - Comment installer un script shell pour Auto redémarrer httpd Apache Server!
Eh bien, j'ai été aux prises avec un de mes serveurs dédiés et viens de trouver ce script sympa qui sera automatiquement redémarrer le serveur httpd Apache si elle s'éteint.
Sauver ce qui suit comme restart.sh:
#! / bin / bash # Apache Process Monitor # Redémarrer Apache Web Server When It Goes Down # ------------------------------------------------- ------------------------ nixCraft project <http://cyberciti.biz/fb/> # Copyright (c) 2003 nixCraft projet <http://cyberciti.biz/fb/> # Ce script est sous licence GNU GPL version 2.0 ou supérieur # ------------------------------------------------- ------------------------ # Ce script est partie de la collection du script shell nixCraft (CNSPM) # Visit http://bash.cyberciti.biz/ pour plus d'information. # ------------------------------------------------- ------------------------ # RHEL / CentOS / Fedora Linux restart Restart = "/ sbin / service httpd restart" # Décommenter si vous utilisez Debian / Ubuntu Linux # Restart = "/ etc/init.d/apache2 restart" # path to pgrep commande Pgrep = "/ usr / bin / pgrep" # Nom de démon httpd, # Sous RHEL / CentOS / Fedora il est httpd # Sous Debian 4. X, il est apache2 HTTPD = "httpd" # Find httpd pid $ Pgrep HTTPD $ () $? if [$? # if apache not running -ne 0] # Si Apache ne fonctionne pas puis # Redémarrer Apache $ RESTART FI
Ensuite, un travail de configuration cron comme ceci: (en général dans votre sa-mise à jour de fichiers sous / etc / cron.d)
* / 5 * * * * root / root / restart.sh> / dev / null 2> & 1
Il ya aussi un programme appelé Monit qui fera une plus grande automatisation.
Taux
Tags: Ampère, le serveur httpd Apache, serveur Web Apache, script cool, serveurs dédiés, fb, Fedora, FI, version GPL de GNU, Linux, serveur linux, LT, root, collection de script, serveur hack, script shell, Ubuntu













