Re[2]: [PHP] daemonized php
Hello, 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. 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. 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. Is there any real examples. I read on devshed article about TCP socket listenig, but I don't like this. tia Uros Monday, July 7, 2003, 2:58:52 PM, you wrote: Can somebody give me any workable example how to run some script written in PHP in Unix console. GD #!/usr/local/bin/php -q GD ?php GD echo Example script; ? I wan't to write some server aplication. So it has to be run in the backgroud. GD Have a look at the process control functions: GD http://php.net/pcntl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] daemonized php
Remember to ?php set_time_limit(0); ? http://us4.php.net/manual/en/function.set-time-limit.php That will allow your PHP program to run infinitely long -- and not time out after x seconds. -Dan On Mon, 2003-07-07 at 09:08, Uros wrote: Hello, 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. 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. 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. Is there any real examples. I read on devshed article about TCP socket listenig, but I don't like this. tia Uros Monday, July 7, 2003, 2:58:52 PM, you wrote: Can somebody give me any workable example how to run some script written in PHP in Unix console. GD #!/usr/local/bin/php -q GD ?php GD echo Example script; ? I wan't to write some server aplication. So it has to be run in the backgroud. GD Have a look at the process control functions: GD http://php.net/pcntl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] daemonized php
Hello, ok what about checking status what this program is doing right now. can this be done with http://www.php.net/manual/en/ref.pcntl.php tia Uros Monday, July 7, 2003, 3:16:35 PM, you wrote: AV #!/usr/local/bin/php -q AV ?php AV set_time_limit(0); AV while(true) AV { AV // do something AV } ? AV Then: AV chmod u+x scriptname AV ./scriptname AV On Mon, 2003-07-07 at 08:41, Uros wrote: Hello! Can somebody give me any workable example how to run some script written in PHP in Unix console. I wan't to write some server aplication. So it has to be run in the backgroud. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] daemonized php
Umm, have your PHP program output a integer to a file somewhere, and just map the integer to a status, example, if 1 exists in the file, it's doing step 1, etc. On Mon, 2003-07-07 at 09:30, Uros wrote: Hello, ok what about checking status what this program is doing right now. can this be done with http://www.php.net/manual/en/ref.pcntl.php tia Uros Monday, July 7, 2003, 3:16:35 PM, you wrote: AV #!/usr/local/bin/php -q AV ?php AV set_time_limit(0); AV while(true) AV { AV // do something AV } ? AV Then: AV chmod u+x scriptname AV ./scriptname AV On Mon, 2003-07-07 at 08:41, Uros wrote: Hello! Can somebody give me any workable example how to run some script written in PHP in Unix console. I wan't to write some server aplication. So it has to be run in the backgroud. -- Adam Voigt ([EMAIL PROTECTED]) Linux/Unix Network Administrator The Cryptocomm Group -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] daemonized php
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php