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
  • 184,866
  • 48
  • 414
  • 792
keepwalking
  • 2,566
  • 5
  • 27
  • 60
  • 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
  • 93,904
  • 19
  • 160
  • 225
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.

tunix
  • 367
  • 1
  • 2
  • 14