I have a script running which builds a web page, which is then displayed on a plasma TV controlled by a PC. This runs continually throughout the day, waiting 30 seconds after it gets done generating the page to do it again. The page itself is set to reload every 15 seconds (via hypertext <meta http-equiv='refresh' content='15'> tag) to pick up the changes shortly after they happen. In order to prevent problems like the page reloading in the browser while the page is being built by the script (which does take a few seconds to parse/format the data), I build the page to a temp file then move it to the /usr/local/apache22/data directory, overwriting the file that was already there. It's worked perfectly so far with one exception.
After several days of running, there was a 403 forbidden error displayed on the plasma. I tapped F5 on the PC to reload the page and all was then well. Figuring this may be the 1 in a million long-shot that the PC was reloading the page (local network, so we're talking next to no load time) in that same split instant the mv overwrote the file, I decided to monitor only. This was early last week, but earlier today the same thing happened and I no longer believe that it's coincidence. Irregardless of what the root cause is, I need to find a solution.
The apache error logs show:
Since it's a script generating the hypertext file, the permissions should always be the same. I do nothing with the permissions of the generated file, which are -rw-r--r-- and root:wheel for ownership.
Other than adding a few lines to my script to change permissions/ownership of the file before it's moved over (already done and monitoring), I'm at a loss. The main problem from a troubleshooting standpoint that this build/reload process happens hundreds or even thousands of times before the problem occurs, so I'm not going to know if something I do fixes the problem for several days. This inconsistency is what led me to think that the problem was a timing issue of the script overwriting the publicly viewable file while the page was being loaded, but this is a very long shot at best.
Any ideas of how to fix it, what's causing the problem, or even how to figure out what's happening?
After several days of running, there was a 403 forbidden error displayed on the plasma. I tapped F5 on the PC to reload the page and all was then well. Figuring this may be the 1 in a million long-shot that the PC was reloading the page (local network, so we're talking next to no load time) in that same split instant the mv overwrote the file, I decided to monitor only. This was early last week, but earlier today the same thing happened and I no longer believe that it's coincidence. Irregardless of what the root cause is, I need to find a solution.
The apache error logs show:
Code:
[Wed Nov 07 08:36:59 2012] [error] [client xxx.xxx.xxx.xxx] (13)Permission denied: file
permissions deny server access: /usr/local/www/apache22/data/PlasmaFile.html
Since it's a script generating the hypertext file, the permissions should always be the same. I do nothing with the permissions of the generated file, which are -rw-r--r-- and root:wheel for ownership.
Other than adding a few lines to my script to change permissions/ownership of the file before it's moved over (already done and monitoring), I'm at a loss. The main problem from a troubleshooting standpoint that this build/reload process happens hundreds or even thousands of times before the problem occurs, so I'm not going to know if something I do fixes the problem for several days. This inconsistency is what led me to think that the problem was a timing issue of the script overwriting the publicly viewable file while the page was being loaded, but this is a very long shot at best.
Any ideas of how to fix it, what's causing the problem, or even how to figure out what's happening?