Solved

php execute deamon process in the background

Posted on 2010-11-24
5
1,155 Views
Last Modified: 2013-12-12
Hi,
I want to run a PHP script in the background (every few minutes).
I downloaded and installed Deamon_System from
http://kevin.vanzonneveld.net/techblog/article/create_daemons_in_php/

But when I try to execute it, I get the following error:
"Notice: Use of undefined constant SIGHUP - assumed 'SIGHUP'..."

I am not sure that I used the roght parameters (it is not explained)


<?php 



require_once "../../bin/php/php5.2.8/PEAR/System/Daemon.php";   //"System_Deamon/System/Daemon.php";  // Include the Class

 

System_Daemon::setOption("SendMailFromQueue", "SendMailFromQueue.php");  // Minimum configuration

System_Daemon::start();

Open in new window

0
Comment
Question by:VapiSoft
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Atr3ides
Comment Utility
You need a PHP distro compiled with POSIX support. Ubuntu comes with it by default, afaik, but if not just recompile PHP with --enable-pcntl
0
 

Author Comment

by:VapiSoft
Comment Utility
I don't want to use POSIX.
How do I I recompile PHP with -enable -pcntl ?
Please note that I downloaded and installed PEAR and of what I read in the Deamon_System, this is all that is needed.
0
 
LVL 2

Expert Comment

by:Atr3ides
Comment Utility
As you can see here, http://www.php.net/manual/en/pcntl.installation.php, PHP doesn't come by default with PCNTL support and on Windows its' unavailable

Installing on Ubuntu:
Login as superuser

Firstly install the php5-dev package:

  apt-get install php5-dev

Create a temporary folder and get php sources

  mkdir php
  cd php
  apt-get source php5

Then go into the extension directory.

  cd php5-5.1.2/ext/pcntl

Compile the extension

  phpize
  ./configure
  make

Copy the extension

  cp modules/* /usr/lib/php5/20051025/

Your php5 library directory might be named something else.
Restart Apache
 apache2 -k restart

Also, you can check http://php.chinaunix.net/manual/zh/ref.pcntl.php for some good insight on how PCNTL and Pear System_Daemon (see comments on that page)
0
 
LVL 2

Accepted Solution

by:
Atr3ides earned 500 total points
Comment Utility
In addition to that, see PEAR's documentation on System Daemon (http://pear.php.net/manual/en/package.system.system-daemon.how-it-works-internally.php) it will tell you they use Process Control Extensions (PCNTL)
0
 

Author Closing Comment

by:VapiSoft
Comment Utility
I did not do it because I saw that it only for Linux (I use LAMP) and I am afraid to change my PHP (that may result that I cannot work with my code).
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now