Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

php execute deamon process in the background

Posted on 2010-11-24
5
Medium Priority
?
1,212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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…
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.

670 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