Solved

php execute deamon process in the background

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
000webhost.com default error log 1 24
Showing random records from database 10 35
Decrypt string by php 7 27
PHP Query return divisible by 3 3 13
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

813 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

13 Experts available now in Live!

Get 1:1 Help Now