php - How to execute a function every n seconds? -
i'm writing monitor in php that's monitoring uptime of host. every n seconds ask host it's status. make cronjob executes every minute, this:
while(1) { check_status(); sleep(60); }
what's efficient way this?
the better method use cron.
cron launch php every minute. if php crash, relaunched. if launch manually php, , crashes, you'll have manually relaunch it. more this, cron, you'll not have care what's happening on machine boot time.
final note : php not best tool make sort of things ;)
cheers,
k.
Comments
Post a Comment