logrotate und apache mal wieder

Apache, Lighttpd, nginx, Cherokee
Post Reply
toppas72
Posts: 18
Joined: 2003-12-17 15:48
 

logrotate und apache mal wieder

Post by toppas72 »

hallo,

habe im forum diverse lösungen für das logrotate-apache-problem gefunden, aber irgendwie gibt es keine methode die 100% funkt. :(
nun, habe ich beschlossen nach den logrotate einen script zu starten, das den apache "richtig" reloaded.

_________________________

#!/usr/bin/perl
print "Cleanup apache...";
system("/etc/init.d/apache stop");
sleep 2;
system("killall -9 apache");
sleep 1;
$tmp = `/usr/bin/ipcs -s | grep www-data`;
@tmp= split(/n/,$tmp);
foreach $tmp (@tmp)
{
$tmp =~ s/[ ]{1,}/ /g;
$pid = (split(/ /,$tmp))[1];
system("/usr/bin/ipcrm sem $pid");
}
system("/etc/init.d/apache start");
_________________________


einziges problem bei diesen script: falls kein apache-prozess gefunden wird, bricht das script ab (logischerweise).
gibt es eine möglichkeit das zu umgehen? also, das er nicht abbricht oder ggf den apache einfach startet.


danke und gruss
toppas
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: logrotate und apache mal wieder

Post by Joe User »

if ... else ... endif
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
toppas72
Posts: 18
Joined: 2003-12-17 15:48
 

Re: logrotate und apache mal wieder

Post by toppas72 »

danke :(

ok, kann mir vielleicht jemand zeigen, wie ich in diesen script eine if...else... schleife einbauen kann? danke
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: logrotate und apache mal wieder

Post by Joe User »

Du kannst zum Beispiel den Exitcode von grep abfragen (0=gefunden/1=!gefunden) und entsprechend reagieren. Da ich von Perl zu wenig Ahnung habe, überlasse ich das Basteln mal Dir 8)
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
toppas72
Posts: 18
Joined: 2003-12-17 15:48
 

Re: logrotate und apache mal wieder

Post by toppas72 »

na ja, habe die holzhammer-methode gewählt. verwende ein script ohne perl, dass den prozess überwacht, ggf apache killt und wieder neustartet. :roll:

gruss
toppas
Post Reply