Re: Re[2]: [PHP] daemonized php

From: Date: Mon, 07 Jul 2003 17:24:46 +0000
Subject: Re: Re[2]: [PHP] daemonized php
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-154209@lists.php.net to get a copy of this message
> Ok let be more specific about my idea. Because I'm better php programer > than C I decided to write this in php. I use comandline php. > > I want to write some daemon to be started > > ./myprog & > > Than this has to be run until I cancel it. But I also want to check > somehow, what this proces is doing right now. ps ax will tell you if it is still running or not. If you need more info you can check out /proc. > for example like in apache. > > you start it with apachectl start. than you can say apachectl restart to > reread config. And for example you could use apachectl status to output > some info about runing server. They coded it that way. If ps ax and /proc are not enough info for you then you'll need to code whatever else you need into your script. > This program I'll make will be run in infinite loop. It will be reading > some file on disk and doing something with this data. > > Do I have to use any usleep function. What is with CPU % when i run such > script. usleep sleeps, there is very little overhead in sleeping. The cpu usage will be determined more by what you make it do when it's not sleeping than when it is. > Is there any real examples. Yes, I already gave you the url: http://php.net/pcntl There's an example right there on the page. It lets you handle hangups, restarts, etc. Copy and paste that and add your own code in the while(1) loop. > I read on devshed article about TCP socket > listenig, but I don't like this. That's pretty much how it's done. If you want to listen to a program you have to use some type of socket, tcp is they way I'd go. -- Greg Donald http://destiney.com/

« previous php.general (#154209) next »