Current time: 05-04-2024, 10:31 AM Hello There, Guest! (LoginRegister)


Post Reply 
Automatischer neustart, wenn Apache down ist.
Author Message
MoritzDorn Offline
Junior Member
*

Posts: 178
Joined: Nov 2007
Reputation: 0
Post: #1
Automatischer neustart, wenn Apache down ist.
Hallo,

da ich jetzt schon weiss, dass der Apache Server morgen gegen 6:25 down gehn wird (leider), habe ich mich auf die Suche nach einem Script gemacht, dass den Apache Server neu startet, wenn dieser down ist.

Warum genau Apache abschmiert ist nicht bekannt, es hat aber nichts mit Attacken zu tun, das konnte ich schon ausschliesen. Es passiert jeden Sonntag um 6:25

Script:
Quote:#!/bin/sh
#
# Apache Process Monitor
#
checkapache=`ps ax | grep -v grep | grep -c httpd`
if [ $checkapache -le 0 ]
then
/usr/local/apache/bin/apachectl startssl
fi

Cronjob:
Quote:*/1 * * * * sh /etc/monitor-apache.sh >/dev/null 2>&1

ist das so korrekt?

mfg
Moritz
02-24-2008 08:09 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Cube Offline
Member
***

Posts: 740
Joined: Apr 2007
Reputation: 9
Post: #2
RE: Automatischer neustart, wenn Apache down ist.
- Bei mir heißt der Apache-Prozess apache2 und nicht httpd.
- Starten würde ich ihn über /etc/init.d/apache2 start.
- Vielleicht wäre davor noch ein "killall php5-cgi" nicht schlecht. Bei einem Apache-Absturz können schon mal diese Prozesse übrig bleiben.
02-24-2008 08:46 AM
Find all posts by this user Quote this message in a reply
Slowman Offline
Member
***

Posts: 332
Joined: Feb 2007
Reputation: 0
Post: #3
RE: Automatischer neustart, wenn Apache down ist.
Hmm... kann es vielleicht sein, das um diese Zeit Backups gezogen werden vom ispCP ?


@Cube

Da mich dies auch interessiert, müsste es so aussehen:

#!/bin/sh
#
# Apache Process Monitor
#
checkapache=`ps ax | grep -v grep | grep -c apache2`
if [ $checkapache -le 0 ]
then
killall php5-cgi
/etc/init.d/apache2 restart
fi

?
02-25-2008 12:11 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Cube Offline
Member
***

Posts: 740
Joined: Apr 2007
Reputation: 9
Post: #4
RE: Automatischer neustart, wenn Apache down ist.
Quote:Hmm... kann es vielleicht sein, das um diese Zeit Backups gezogen werden vom ispCP ?
Die werden aber täglich gemacht. Ich würde eher schauen ob die Jobs in cron.weekly um diese Zeit laufen und wenn ja, was für Jobs das sind.

Das Skript müsste so funktionieren. Einfach mal ausprobieren. Wink
02-25-2008 12:21 AM
Find all posts by this user Quote this message in a reply
MoritzDorn Offline
Junior Member
*

Posts: 178
Joined: Nov 2007
Reputation: 0
Post: #5
RE: Automatischer neustart, wenn Apache down ist.
Folgende Scripte werden ausgeführt:

man-db:
Quote:#!/bin/sh
#
# man-db cron weekly

set -e

if ! [ -d /var/cache/man ]; then
# Recover from deletion, per FHS.
mkdir -p /var/cache/man
chown man:root /var/cache/man
chmod 2755 /var/cache/man
fi

# regenerate man database
if [ -x /usr/bin/mandb ]; then
# --pidfile /dev/null so it always starts; mandb isn't really a daemon,
# but we want to start it like one.
start-stop-daemon --start --pidfile /dev/null \
--startas /usr/bin/mandb --oknodo --chuid man \
-- --quiet
fi

exit 0

rkhunter:
Quote:#!/bin/sh

RKHUNTER=/usr/bin/rkhunter

if [ ! -x $RKHUNTER ]; then
exit 0
fi

# source our config
. /etc/default/rkhunter

case "$CRON_DB_UPDATE" in
[Yy]*)
OUTFILE=`mktemp` || exit 1
if [ "$DB_UPDATE_EMAIL" = "no" ]
then
$RKHUNTER --versioncheck 1>/dev/null 2>$OUTFILE
$RKHUNTER --update 1>/dev/null 2>$OUTFILE
else
(
echo "Subject: [rkhunter] Weekly database update"
echo ""
$RKHUNTER --versioncheck
$RKHUNTER --update
) | /usr/sbin/sendmail $REPORT_EMAIL
fi
if [ $(stat -c %s $OUTFILE) -ne 0 ]; then
(
echo "Subject: [rkhunter] Weekly database update"
echo ""
cat $OUTFILE
) | /usr/sbin/sendmail $REPORT_EMAIL
fi
rm -f $OUTFILE
;;
*)
exit 0
;;
esac

sysklogd:
Quote:#! /bin/sh

# sysklogd Cron script to rotate system log files weekly.
#
# If you want to rotate logfiles daily, edit
# this script and /etc/cron.daily/sysklogd to get
# the logfiles in sync (they must not occur in both
# files).
#
# This is a configration file. You are invited to edit
# it and maintain it on your own. You'll have to do
# that if you don't like the default policy
# wrt. rotating logfiles (i.e. with large logfiles
# weekly and daily rotation may interfere). If you edit
# this file and don't let dpkg upgrade it, you have full
# control over it. Please read the manpage to
# syslogd-listfiles.
#
# Written by Ian A. Murdock <imurdock@debian.org>.
# $Id: cron.weekly,v 1.10 2004-03-31 16:18:15 joey Exp $

test -x /usr/sbin/syslogd-listfiles || exit 0
test -x /sbin/syslogd || exit 0
test -f /usr/share/sysklogd/dummy || exit 0

set -e

cd /var/log
for LOG in `syslogd-listfiles --weekly`
do
if [ -s $LOG ]; then
savelog -g adm -m 640 -u root -c 4 $LOG >/dev/null
fi
done

# Restart syslogd
#
/etc/init.d/sysklogd reload-or-restart > /dev/null
02-25-2008 01:31 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Snatch Offline
Junior Member
*

Posts: 42
Joined: Nov 2007
Reputation: 0
Post: #6
RE: Automatischer neustart, wenn Apache down ist.
Hallo,

ich benutzt dazu Monit.
Das Überwacht gleich noch andere
Prozesse. Startet bei mir den Apache
auch öfter mal neu, aber ohne Ausfall.

Habe z.B. die Load Grenzen ganz
klein gestellt. Und der Apache wird
ja so schnell gestartet, dass dies dem
User nicht auffällt-

Gruß
Snatch
02-25-2008 04:14 AM
Find all posts by this user Quote this message in a reply
MoritzDorn Offline
Junior Member
*

Posts: 178
Joined: Nov 2007
Reputation: 0
Post: #7
RE: Automatischer neustart, wenn Apache down ist.
Hi,

das habe ich jetzt getestet, und das geht soweit auch, bin mal gespannt, ob es am Sonntag auch funktioniert.

Quote:#!/bin/sh
#
# Apache Process Monitor
#
checkapache=`ps ax | grep -v grep | grep -c apache2`
if [ $checkapache -le 0 ]
then
killall php4-cgi
/etc/init.d/apache2 restart
echo neu gestartet
else
echo läuft
fi
03-15-2008 03:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
anne123 Offline
Junior Member
*

Posts: 237
Joined: Oct 2007
Reputation: 0
Post: #8
RE: Automatischer neustart, wenn Apache down ist.
Wow sowas habe ich doch gesucht. Nur wo muß ich den Code genau einfügen wenn ich das mit winscp machen will?
Ist das richtig, das der Apache sofort neu startet wenn er ausfällt, oder kann man das auch so machen, das der Apache sagen wir mal aller 5 Minuten neu startet?
10-14-2008 06:27 AM
Find all posts by this user Quote this message in a reply
Top44 Offline
Member
***

Posts: 271
Joined: Sep 2007
Reputation: 1
Post: #9
RE: Automatischer neustart, wenn Apache down ist.
Bedenke das php4-cgi ersetzt werden muss da seit RC6 nicht mehr unterstützt!
10-14-2008 07:43 AM
Find all posts by this user Quote this message in a reply
elitepilot Offline
Member
***

Posts: 352
Joined: Feb 2008
Reputation: 0
Post: #10
RE: Automatischer neustart, wenn Apache down ist.
nimm dir die Zeit und nutze Monit. Da ersparrst du dir jedemenge Arbeit.
10-14-2008 07:48 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)