Skript:
Code: Alles auswählen
#!/bin/bash
#
# ueberprueft apache2 ob aktiv oder inaktiv
#
if [ "test -f /var/run/apache2.pid" ] ;
then
# Apache2 aktiv
echo "Apache2 ist gestartet"
echo
echo "PID:"
cat /var/run/apache2.pid
else
# Apache2 nicht aktiv
/etc/init.d/apache2 start
echo "Apache2 wurde gestartet!"
fi
# EOF
Ausgabe:
Code: Alles auswählen
root |>> /etc/init.d/apache2 stop
Stopping web server: Apache2.
root |>> ./apache2test
Apache2 ist gestartet
PID:
cat: /var/run/apache2.pid: No such file or directory
root |>> /etc/init.d/apache2 start
Starting web server: Apache2.
root |>> ./apache2test
Apache2 ist gestartet
PID:
32545
Hab die Abfrage auch schon auf anderen Wegen versucht, z.B. mit "pgrep apache2", allerdings hatte ich hier genau die gleichen Probs.