This is a discussion on "reading a log file one line at a time depending on timestamp" within the PHP Forum section. This forum, and the thread "reading a log file one line at a time depending on timestamp are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
reading a log file one line at a time depending on timestamp
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
reading a log file one line at a time depending on timestamp
Hi,
Currently I am attepting to create a stats package for my companies website (yes my life would be 100% stress free if I was allowed to use a standard/commercial stats package So far things are all good, and ive progressed quite far. But ive hit a snag. At the moment im reading in the WHOLE log file and sorting it into an array and passing the neccesary data to mysql. Easy peasy. But my boss has pointed out to me that as the site gets more and more traffic the log gets bigger, and if it gets to big the servers memory will overload, and we all know what happens then! So what I need to do is read in the file one line at a time. and compare the timestamp to the last time the script was run. If the timestamp in the log is less than the last timestamp for when the file was run dont read it. If it is more than defiently read it. so far my code looks like so...
2007-11-22 23:59:59 W3SVC10019 **.***.***.*** GET /images/e-br... then grab '2007-11-22 23:59:59' and convert to timestamp ( strtotime ) then compare it to the mysql stored last run time of the script. If the timestamp is less than the mysql version. Ignore If it is more read it in. How do I read one line at a time?? But only the first date/time part, and then figure out true/false?? I hope this all makes sense. Ive tried to explain this fully. If it all still does not make sense, please ask for more info! Ok thanks in advance! Eon201 |
|
|
|
||||
|
Re: reading a log file one line at a time depending on timestamp
To read one file at a time use
fgets(); and check if you have reached the end of the file using feof
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| images loading time changes depending on browser | thosecars82 | Web Page Design | 5 | May 19th, 2008 14:57 |
| Edit a specific line of a file??? | WebNinja | PHP Forum | 5 | Feb 10th, 2008 11:50 |
| [SOLVED] Reading as text file backwards | eon201 | PHP Forum | 4 | Nov 8th, 2007 10:53 |
| Syntax error with Ajax file reading | Paramiliar | JavaScript Forum | 0 | Aug 12th, 2007 16:48 |
| Time line question | autumn_whispers2me | Flash & Multimedia Forum | 9 | May 26th, 2005 00:43 |