1

I need to monitor the access.log of a website. I can use the unix tail -f in my php but the problem is that when the http server is restarted, the file is truncated and the read stops.

I need this feature in php.

hakre
  • 193,403
  • 52
  • 435
  • 836
keepwalking
  • 2,644
  • 6
  • 28
  • 63
  • you probably missed something in your question. it's not clrear, what functionality are you trying to achieve. is it some web online monitor with ajax? – heximal Jun 27 '11 at 10:51

2 Answers2

2

Haven't tried it, but maybe Inotify can help you:

inotify is a Linux kernel subsystem that acts to extend filesystems to notice changes to the filesystem, and report those changes to applications.

There's a php extension for inotify, see http://docs.php.net/manual/en/book.inotify.php

VolkerK
  • 95,432
  • 20
  • 163
  • 226
1

try using tail -F not -f -- this way it'll continue to monitor the file even if the file is truncated or deleted. it's not the best way though but saves the day.

Alper Kanat
  • 376
  • 1
  • 2
  • 16