Re: Re[4]: [PHP] daemonized php
> But I sill wan't to hear from you php experts. Anybody do such thing in > real example or this is can only be my dream. Although I may not be the PHP expert you seek, I do have lots of command line PHP scripts: mailings, spam filter, db maintenance.. I even have an IRC bot written in PHP. -- Greg Donald http://destiney.com/ -- 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
Re: [PHP] daemonized php
Uros wrote: Than this has to be run until I cancel it. But I also want to check somehow, what this proces is doing right now. If you want it to be realy nice, use shared memory. But this extension is not enabled by default and is available only on unices. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[4]: [PHP] daemonized php
Hello Adam, I was thinking about using parent and child proces. So when i start server it will call some child process and that I can ask parent what his child is doing. I found some examples on php.net. But I sill wan't to hear from you php experts. Anybody do such thing in real example or this is can only be my dream. tia Uros Monday, July 7, 2003, 3:33:47 PM, you wrote: AV> Umm, have your PHP program output a integer to AV> a file somewhere, and just map the integer to AV> a status, example, if "1" exists in the file, it's AV> doing step 1, etc. AV> 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> > 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> 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[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> 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: [PHP] daemonized php
#!/usr/local/bin/php -q Then: chmod u+x scriptname ./scriptname & 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. > > > -- > Best regards, > Uros -- 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
Remember to 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> 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 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> 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: [PHP] daemonized php
> Can somebody give me any workable example how to run some script written in > PHP in Unix console. #!/usr/local/bin/php -q > I wan't to write some server aplication. So it has to be run in the > backgroud. Have a look at the process control functions: http://php.net/pcntl -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] daemonized php
Uros -- ...and then Uros said... % % Hello! Hi! % % Can somebody give me any workable example how to run some script written in % PHP in Unix console. Sure. php -q /path/to/script/name (assuming you have the command-line version of php, which you may not, and that your script doesn't need apache to feed it env vars). % % I wan't to write some server aplication. So it has to be run in the % backgroud. Then tack '&' on the end of the line above. HTH & HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
Re: [PHP] daemonized php
start your PHP files with: #! /usr/bin/php Replace /usr/bin/php with the path to php. You will need to make the file executable by chmod ing it. (try: $ chmod +x ./yourscript.php ) As a side note, starting any text file with #! followed by the path to a language interpreter, and chmoding the file so that it is executable will allow you to send the rest of the file to the interpreter and run it as a full fledged program. -Dan 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. > > > -- > Best regards, > Uros > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] daemonized php
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. -- Best regards, Uros -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php