Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am running xubuntu 12.04 with apache2 as a local server. I recently wrote a while loop statement in 'testing.php' that was supposed to retrieve a remote xml file from a url and save that to a file located on the local server. I ran this code not realizing that the loop was infinte. The browser starts to load, and a few seconds after my computer starts to obviously slow down to the point of ceasing to function swiftly. I restart my computer. I check the error.log file, loading of this file takes ~30 seconds, unusual compared to other accesses. Once the 'error.log' file loads it starts to display hundreds of lines of errors relating to this while loop. So I immediately delete that line of code and fix it completely. Now the program is fixed and works properly, yet every time I open 'error.log', it takes a while to open and the same errors are being logged. Even when I have not ran 'testing.php' prior to opening the 'error.log'

Here are some of the errors being logged, keep in mind I know why I got the errors, I just do not know why the errors are still being logged:

[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Notice:  Undefined variable: count in /home/sebastian/jasone_co/Testing/testing.php on line 96
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  file_get_contents(jasoneatherly.tumblr.com/api/read/?type=photo&&start=0&&num=25): failed to open stream: No such file or directory in /home/sebastian/jasone_co/Testing/testing.php on line 85
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fopen(/home/sebastian/jasone_co//Testing/Test-XML/TumblrXML_0-25.xml): failed to open stream: No such file or directory in /home/sebastian/jasone_co/Testing/testing.php on line 86
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /home/sebastian/jasone_co/Testing/testing.php on line 87
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/sebastian/jasone_co/Testing/testing.php on line 88
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  simplexml_load_file(): I/O warning : failed to load external entity "/home/sebastian/jasone_co//Testing/Test-XML/TumblrXML_0-25.xml" in /home/sebastian/jasone_co/Testing/testing.php on line 90
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /home/sebastian/jasone_co/Testing/testing.php on line 91
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /home/sebastian/jasone_co/Testing/testing.php on line 91
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Notice:  Undefined variable: count in /home/sebastian/jasone_co/Testing/testing.php on line 96
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  file_get_contents(jasoneatherly.tumblr.com/api/read/?type=photo&&start=0&&num=25): failed to open stream: No such file or directory in /home/sebastian/jasone_co/Testing/testing.php on line 85
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fopen(/home/sebastian/jasone_co//Testing/Test-XML/TumblrXML_0-25.xml): failed to open stream: No such file or directory in /home/sebastian/jasone_co/Testing/testing.php on line 86
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /home/sebastian/jasone_co/Testing/testing.php on line 87
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/sebastian/jasone_co/Testing/testing.php on line 88
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  simplexml_load_file(): I/O warning : failed to load external entity "/home/sebastian/jasone_co//Testing/Test-XML/TumblrXML_0-25.xml" in /home/sebastian/jasone_co/Testing/testing.php on line 90
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /home/sebastian/jasone_co/Testing/testing.php on line 91
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Notice:  Trying to get property of non-object in /home/sebastian/jasone_co/Testing/testing.php on line 91
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Notice:  Undefined variable: count in /home/sebastian/jasone_co/Testing/testing.php on line 96
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  file_get_contents(jasoneatherly.tumblr.com/api/read/?type=photo&&start=0&&num=25): failed to open stream: No such file or directory in /home/sebastian/jasone_co/Testing/testing.php on line 85
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fopen(/home/sebastian/jasone_co//Testing/Test-XML/TumblrXML_0-25.xml): failed to open stream: No such file or directory in /home/sebastian/jasone_co/Testing/testing.php on line 86
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /home/sebastian/jasone_co/Testing/testing.php on line 87
[Sun May 27 22:07:49 2012] [error] [client 127.0.0.1] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/sebastian/jasone_co/Testing/testing.php on line 88

I have also tried to locate any zombie or defunct processes to no avail. Here is what I get when I run ps -C apache2:

sebastian@Lucight:~$ ps -C apache2
  PID TTY          TIME CMD
 2875 ?        00:00:00 apache2
 2880 ?        00:00:00 apache2
 2881 ?        00:00:00 apache2
 2882 ?        00:00:00 apache2
 2883 ?        00:00:00 apache2
 2884 ?        00:00:00 apache2
 2901 ?        00:00:00 apache2
 2903 ?        00:00:00 apache2
 2904 ?        00:00:00 apache2
 2905 ?        00:00:00 apache2
 2906 ?        00:00:00 apache2

As I stated before, restarting my computer does nothing to fix this.

share|improve this question

closed as off topic by mgorven, EightBitTony, John Gardeniers, Ward, Khaled May 29 '12 at 8:29

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

    
Those log entries are from Sunday, are you sure it's still logging the error now How about tail -f on the log file, is it still adding new lines? –  EightBitTony May 28 '12 at 21:17
    
Do the errors just populate when I open the error.log? it just seems like the errors are happening when I open the file, maybe I just need to clear the log file. –  user122672 May 28 '12 at 21:28
    
and it does not add new errors, I think due to the mass amounts of errors from that single bad call causes this poor load time. I will try to clear the error.log file. –  user122672 May 28 '12 at 21:41
    
The only problem you have is that you have poorly written code. It really is that simple. Fix your code and the errors will no longer be logged. Why you chose Sf to post this is a mystery to me. Please read our FAQ. –  John Gardeniers May 29 '12 at 0:57
    
i am an uber noob my apologies... –  user122672 Jul 10 '12 at 7:54

1 Answer 1

up vote 1 down vote accepted

First try to see what is the size of that file. Maybe its so big and opening it need time.

Execute tail -f error.log to see if script still generates errors.

Executing tail error.log should also tell from what date are the last entries.

If tail shows that no errors are loging you can safely delete that file if its to big. (some errors logs can have sizes in GB).

You can clean that error.log using command cat /dev/null > error.log

But if tail shows that error are still loging ...hmm then I would say that there somewhere are still errors that need to be fixed.

My answare is much more guessing because the information you have given are not clear as to the cause

share|improve this answer
    
I will try clearing the log. –  user122672 May 28 '12 at 21:42
    
The size of the error.log file is ~596mb. I tried the cat /dev/nll > error.log command it didn't seem to clear it. –  user122672 May 28 '12 at 21:46
    
I ended up editing the the error.log file using gksudo gedit /var/log/apache2/error.log, deleted all the contents and all seems well. thanks for everyone's help. I am a noob. –  user122672 May 28 '12 at 21:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.