taking down the system |
I have a cron job that I will run every Sat night.
One of the first things it does is: $_SERVER['MAINT']=1; This creates a $_Server variable and sets it to one. At the end of the cron job I use: $_SERVER['MAINT']=0; echo('done with cron_job'); exit(0); This correctly sets the MAINT to zero and exits. But when a user brings up my main application, in the index() I have: if ($_SERVER['MAINT']==1) { show_error("The Substantiator is down for weekly maintanance. ",500,"System down"); exit(0); } This is not working. When I stop with the debugger on the line above and look for $_Server['MAINT']==1, it doesn't exist. This causes a real error instead of the fake one I am trying to create. I thought the $_SERVER variable is global on the Apache. What am I doing wrong? Rich
proof that an old dog can learn new tricks
I haven't played with setting variables in _SERVER global in this manner nor have I seen it in the wild.
You could go with a lock file solution to track when the cron starts and ends for your other files Along the lines of PHP Code: file_put_contents('cron.lock', time()); In your index, you can do PHP Code: if(file_exists('cron.lock'))
Thanks. Where does cron.lock go? I can't seem to find it. Is it hidden?
proof that an old dog can learn new tricks
(08-26-2018, 06:06 AM)richb201 Wrote: Thanks. Where does cron.lock go? I can't seem to find it. Is it hidden?cron.lock is a temp file that will be created by the file_put_contents function and it will be removed once the cron script has finished running. |
Welcome Guest, Not a member yet? Register Sign In |