Basically you need to look at this as two completely seperate problems:
- How do I post an event into a subscribers notification queue
- How do I do near-instant notification to subscribed clients
Let's start with 2.)
There are lots of approaches to this very common problem, many of which have dependencies. If you control the server (on a root level) you can chose from many, but if you want this to be hostable in any low-cost PHP environment, I recommend you go for long polling as a slightly aged nut well-understood and easy technology: Have you clients poll the server (via AJAX) and the server-sided poll script watch for events on the server. Return from the script only after something like 30-120 seconds to stay inside timeouts (in the meantime maybe send some placeholders). If an event happens, return immediately with the event.
This solves your continually running script problem: The clients keep it running.
Assuming you got this, 1. seems quite trivial: Post the event to a central queue (e.g. Database) and kick the pollers e.g. via SHM or file deletion.