System_Daemon HowTo
Hi,
I need a background app. which is processing every seconds. It should call a php file includes update mysql inserts etc. i've tried cronjobs but it works every min. it's not good for me. i've search about Daemons and i finally found Pear::System__Daemons extension.i installed it, but i can't start it. I download package and upload like /home/user_xx/public_html/daemons/... Can you help me about this? Thanks. |
Quote:
If it's written in PHP, why don't you just put a sleep statement in there, and loop back through after a short pause? |
Thanks for reply,
You can check here: http://pear.php.net/manual/tr/packag...les.simple.php --- when i try to exucute app file like -> ~ chmod a+x ./Daemon.php ~ ./Daemon.php error: root@server [/home/user_xxx/public_html/daemons]# ./Daemon.php : No such file or directory : command not found2: ./Daemon.php: line 3: //: is a directory ./Daemon.php: line 4: syntax error near unexpected token `(' '/Daemon.php: line 4: ` $value = ini_get("error_reporting"); --- i just do instructions of Pear page -> http://pear.php.net/manual/en/packag...tem-daemon.php it should works every seconds. (always) i need this because when i try solve this problem with php loops it takes %70+ memmory. Server software is latest CentOs 32Bit. Packages installed. |
this is "Daemon.php" -> exucute
Code:
<?php this is other file -> "Daemon" Code:
#!/usr/bin/php -q |
Quote:
If you're trying to call this from the command-line, there are much better languages than PHP. Perl or bash would be best for such things, in my opinion...PHP is normally used for web-applications. And if your program is using 70+% of resources just by looping...you've got problems in your code. Sleeping for a second or two shouldn't be a problem, unless your processes aren't terminating within that window. If they're not, put a check in to see if it's done, before sleeping. |
All times are GMT -5. The time now is 01:29 PM. |