Solved

php execute deamon process in the background

Posted on 2010-11-24
5
1,169 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
ID: 34208548
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
ID: 34208741
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
ID: 34208815
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
ID: 34208829
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
ID: 34211206
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

919 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

17 Experts available now in Live!

Get 1:1 Help Now