FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Script to automatically restart Apache (for server 1)





Daniel15
Hi,
I found a nice script to automatically restart Apache (if it's down). Hopefully, this will control the downtime on server 1

Here's the script:
Code:

checkapache=`ps ax | grep -v grep | grep -c httpd`
if [ $checkapache -le 0 ]
then
/etc/init.d/httpd restart
fi


Nice and simple Very Happy It just checks if httpd is on the process list, and if not, restart it. Quite a nice little script.
Just set that to run every 10 minutes as a cron job on the server (it will cause very little server load, if any, it takes less than a second to check if Apache is running), and our Apache problems are solved.
n0obie4life
What about mySQL? What about Eximstats? What about POP3?

Directadmin does them all Rolling Eyes.
Bondings
That script won't help. Lately apache just stops working, but is still running. (so the script will think it is up)
Daniel15
Bondings wrote:
That script won't help. Lately apache just stops working, but is still running. (so the script will think it is up)

Well, maybe the data centre can help you sort it out?

Would an upgrade to Apache 2 help?
n0obie4life
daniel15 wrote:
Bondings wrote:
That script won't help. Lately apache just stops working, but is still running. (so the script will think it is up)

Well, maybe the data centre can help you sort it out?

Would an upgrade to Apache 2 help?


He won't upgrade to Apache 2 Very Happy.

I guess switching to Directadmin and totally getting rid of cPanel will help Rolling Eyes.
Rhysige
perhaps load a web page from server 1 if page load fails reboot apache?
n0obie4life
Rhysige wrote:
perhaps load a web page from server 1 if page load fails reboot apache?


To reboot apache, you need a shell script. Or just do it from WHM which is an hassle.

WHM = Web Host Manager.
simplyw00x
Use lynx commandline or cURL to fetch a page on the server within in a shell script and restart apache based on what it returns.
cepher
Wow...other people feel my pain.

But really... I used samba remote computer using for my network...

if cpanel is that big of an issue...then uhh...look into some remote software
Daniel15
simplyw00x wrote:
Use lynx commandline or cURL to fetch a page on the server within in a shell script and restart apache based on what it returns.

Nice idea... What about a shell script that runs wget http://www.frihost.com/ and checks if Apache is working? That would be great!

Only problem is I don't have much shell scripting experience (that script I posted was just sitting on my hard drive from ages ago). Maybe if someone writes up a script, Bondings could implement it?

I think to restart apache, you need to run /etc/init.d/httpd restart or apachectl -k restart (can't remember which, I'm not good with Linux programming)
Related topics
installing apache,mysql and php on windows
Apache Server on Win XP Pro
Less downtime
apache server logs not working
apache stopped? - READ - CURRENT SERVER 2 DOWNTIME
Make your own PHP/APACHE/MySQL server at home.
Lineage II (C4 chronicle)
Apache server logs turned off
Server 2 Timing Out
Apache Server just "kills" my machine
Apache server with php???
How to Install GD in local apache server ? | hELP !!
PHP5 MySQL Config on XP
Server 3: DNS offline
Reply to topic    Frihost Forum Index -> General -> Suggestions

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.