Web Hosting Talk







View Full Version : Apache rebooting?


raqman
12-19-2001, 03:49 AM
Anyone know how I can set apache to automatically reboot the httpd server once an hour?
Thanks in advance.
(please be more specific than just saying crontab)

dnid
12-19-2001, 05:09 AM
login as root and create a simple shell-script:

#!/bin/sh
/etc/rc.d/init.d/httpd restart
if test $? != 0; then
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/httpd start
fi


copy this script to your dir /etc/cron.hourly and make it executeable: chmod 700 myscript.sh

HTH
Daniel

raqman
12-19-2001, 05:51 AM
I know crontab scripts are supposed to have a blank line at the bottom, but is the fi a typo or should I put that and then the blank line?

Thanks.

NewonNet
12-19-2001, 05:59 AM
fi is not a typo.


It is the end tag for the IF statement.

AlaskanWolf
12-19-2001, 06:35 AM
as root run

crontab -e

then add

0 * * * * /etc/rc.d/init.d/apache restart

and save

raqman
12-24-2001, 11:30 PM
Perhaps I'm just doing something wrong, but neither method worked for me. I was unable to figure out how to edit using crontab -e, and the script gave me errors.

Any ideas?

dnid
12-25-2001, 03:40 AM
Perhaps I'm just doing something wrong, but neither method worked for me

Do you have a RaQ2 or RaQ1? Than you'll have to change the path to the init.d-script. Sorry, I don't know the exact path, but I think it's /etc/rc.d/init.d/httpd.init restart

Daniel

raqman
12-25-2001, 04:32 AM
Raq 4i actually.

dnid
12-25-2001, 04:36 AM
what error do you get when you try using the script?
It works perfect for me.

Are you logged in as root? Did you chmod the script? Did you try to execute it manually with ./scriptname.sh ?

Daniel