Restar Otomatis Ketika Server Down

Wednesday, March 06, 2013 , , , 0 Comments

oke kali ini ane mau ngasih tips cara otomatis ngerestar server ketika donw. ini ane dapet dari IHT postingan nya bapak admin yang ganteng wkwkwkwkwk *boong dikit. Oke langsung aja deh buat yang mau coba silakan baca yang bener yah, ini juga sebagai catetan ane kalo lupa :D

Code:
#!/bin/bash# Apache Process Monitor
# -------------------------------------------------------------------------
# RHEL / CentOS / Fedora Linux restart command
RESTART="/sbin/service httpd restart"


# uncomment if you are using Debian / Ubuntu Linux
#RESTART="/etc/init.d/apache2 restart"


#path to pgrep command
PGREP="/usr/bin/pgrep"


# Httpd daemon name,
# Under RHEL/CentOS/Fedora it is httpd
# Under Debian 4.x it is apache2
HTTPD="httpd"


# find httpd pid
$PGREP ${HTTPD}


if [ $? -ne 0 ] # if apache not running
then
# restart apache
$RESTART
fi




klo pakke turunan rhed begitu.. klo pake turunan debian dkk,, di uncomment aja itu baris nya...
terus save.. kemudian bikin in cron..


Code:
*/5 * * * * /path/to/script.sh >/dev/null 2>&1
ubah /path/to/ nya dengan directory file nya...


selesai deehh restart cronnya..
Code:
/etc/init.d/cron restart
kelar.. semoga bermanfaat

Dharmo

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

0 comments: