Solved

php execute deamon process in the background

Posted on 2010-11-24
5
1,188 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 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