Detecting apache restart or a variable that dies with apache

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sun Mar 16, 2014 2:55 pm

Detecting apache restart or a variable that dies with apache

Postby schworak » Sun Mar 16, 2014 3:05 pm

This may seem odd but does anyone know a way to store a variable that only exists as long as apache is running or the PHP server is running?

Or is there some way to know when apache restarts?

I have a couple pages that run into trouble if for any reason they are running and apache restarts. Such as a server reboot or simply restarting the apache server from the command line.

I want to be able to do some clean-up if this situation is detected. I know I can create a file when the process starts and delete it after. Then if it is there when the process trys to start again clean-up is done first. But that is somewhat what I am doing except if that file exists I don't run the script because it could already be running and the script can only run one at a time. It is a visious cycle on this page.

Here is what I am doing in a nut shell so any ideas are welcome.

* Page loads
* If the magic file exists, notify the user and exit
* No file so create the magic file
* Do a long running process
* Delete magic file
* Exit

The problem happens if apache restarts during the "Do a long running process" step.

Thanks for any suggestions.

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests