daemon without pcntl_fork

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Does anybody know how to use PHP as a daemon without the use of pcntl_fork.

http://php.net/pcntl_fork

I don't want to have to have a person have a special/custom compilation
of PHP just to run a simple daemon.

My system:  OpenBSD 4.5 w/PHP v5.2.8

I want to launch a daemon out of the /etc/rc.local when the system starts.

My goal is to write a script that will be launched from /etc/rc.local
when a system boots.  I want it to be detached from any shell or ssh
login that I launch it from also.

Anybody have any idea on how to do this?

I have played with system() and it does work.

test.php:
<?php
echo 'Starting';
system('/usr/local/bin/php test_cli.php >/dev/null &');
echo 'Done';
?>

test_cli.php
<?php

for( $i=1; $i<=10; $i++ ) {
        echo "Echo {$i}\n";
        sleep(1);
}

echo 'Done';

?>

The above, when called, launches test_cli.php and detaches it from the
cli and returns to the system prompt


Well, after writing all this out, I think I have answered by own question.

If anybody else has a better suggestion, I am all ears.

If you have a better way of doing it, please share.

Also, a second piece to this would be a script to manage
(start/stop/restart/etc...) the parent daemon.

Something along the line of apachectl or similar.

TIA!

Update to the last email also.

I found another device that does RS232 to ethernet:

http://www.hw-group.com/products/portstore2/index_en.html

Anybody work with one of these?

Again, thanks!

Jim Lucas


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux