Does anybody know how to use PHP as a daemon without the use of 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.

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


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

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.


Update to the last email also.

I found another device that does RS232 to ethernet:

Anybody work with one of these?

Again, thanks!

Jim Lucas

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to