httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Andersson" <>
Subject Re: Executing Apache commands with PHP (module)
Date Tue, 25 Jun 2002 05:07:09 GMT
Jochen Kaechelin wrote:

> Am Freitag, 21. Juni 2002 09:04 schrieb Robert Andersson:
> > If you consider that this would mean to shut down the server
> > during the request, it seems a bit weird when you think about it.
> > I actually tried to do a similar thing, but no good outcome.
> > It would probably be better that your php-script put a note
> > somewhere, which another process can pick up and restart the
> > server. That would be better than restarting every hour (as
> > RuneImp suggested), to avoid restart when it's not needed.
> > Although, you also could have a process that frequently checks
> > the config file(s), and restart the server if it's been changed
> > (ie. different modification time).
> Ok, I will give it a try!
> What about system load when I run
> /usr/local/apache/bin/apachectl graceful
> every 5 minutes?

You shouldn't do that every five minutes. If you lock at a certain
frequency, that should be at least an hour.

> Or, how can I run a script in a loop which looks for modified
> conf-files generated by my php-apache-configure-webfrontend?

That is better, but I'm sorry to say that I do not know how to code such
program on UNIX. The main thing I don't know, is how to let it go in the
background. I'll try to give you a Perl example, although I haven't tested
it, and do not suggest that it is the best approach:


@checklist = (
@changelist = ();
$isnt_first = 0;
while(1) {
    for($i = 0; $i <= $#checklist; $i++) {
        @fileinfo = stat($checklist[$i]);
        ## Only if not the first loop, and mod time is
        ## more than the stored time
        if(isnt_first && $fileinfo[9] > $changelist[$i]) {
            ## ... restart apache ???
            system('/usr/local/apache/bin/apachectl graceful');
            ## No more changed file should cause a restart
            isnt_first = 0;
        ## Store modification time for the file
        $changelist[$i] = $fileinfo[9];
    $isnt_first = 1;
    ## Sleep for a while...

Now, I have no idea if this works as intended, but it should give you an
idea of how to do it.
You have a list of files (@checklist) that if any is modified will cause
Apache to be restarted. @changelist is first build up with the modification
time of corresponding files. In each check, if any file's current
modification time is more than the last stored, Apache should be restarted.
I suggest you talk to someone (perhaps yourself?) that know the best way to
have such a program running. It would probably be a good idea to implement a
log, that reports each restart and what file that caused it.

Robert Andersson

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message