Forking A PHP Process Into The Background In A Web Server Environment
I have installed the PCNTL functions[1] on my PHP enabled webserver
in the interest of being able to fork a process into the background so I
can do some heavy processing but return control of the browser back to the
user rather quickly.
However, after mucking about with PCNTL for a while and not getting the
results I expected, I finally stumbled across this line in the opening
parragraph on PCNTL functions on PHP.net:
"Process Control should not be enabled within a webserver environment and
unexpected results may happen if any Process Control functions are used
within a webserver environment."
Seems like they should bold and highlight in red that line, but I digress.
In any case, can anyone suggest a way to fork a process off to unload a
large amount of processing and return control of the web browser to the
user? All the examples and whatnot I have found assume a CLI version of
PHP. I want to do this on the web server!
[1]I am running Apache2/PHP4.3 on RHEL 4. I downloaded the RPM for PCNTL
at
View Complete Forum Thread with Replies
Related Forum Messages:
Forking A Process
What i should i use to create a script that does two things at the same time ie while sorting/execeuting a process, how can i show another screen with valid data on it?
View Replies !
Run Process In Background
I want to run process from my php script in background. I try different functions from functions list but all of them whaiting for process ending. How can I run `wget -b ...` and finish my script, but wget must still working? I use PHP5, Linux, Apache2.
View Replies !
Background Process
I would like to create a script that acts like a background process. Basically once every hour, it will access a website, gather data from it, and write that data to a file on a remote server. The PHP code would be running on this same server. Is this type of non user activated, constantly running code possible?
View Replies !
Exec Background Process
I want have PHP call another process (another PHP script at the moment but it may end up being a binary) in the background and not wait for process to complete, but rather instantly jump the the next line of code. I've tried things like: exec("./script.php &"); // script.php has executable permissions set exec("at -f ./script.php now"); // and #!/usr/bin/php at the top of the code Neither seem to work. They both execute script.php, but both hang around until script.php has completed.
View Replies !
XP Exec Background Process
I was trying to exec a background process on XP using PHP CLI, but could not get it to work. Suppose the command I want to spawn off is "cmd". On *nix, it is as easy as putting ampersand "&" at the end of the command. I tried the following on XP without working. exec("cmd"); exec("cmd >NUL"); exec("cmd /c cmd"); exec("start /b cmd"); I tried many combination, but on each one, PHP waits for cmd to exit before continuing. Doing this in Windows script host (cscript) is simple: Set objShell = CreateObject("WScript.Shell") objShell.Run "cmd", 0, False The "False" parameter causes the Run method to continue immediately without waiting for the command to finish. So I could make my PHP file exec a VBS file that does the actual background execution of my command. PHP exec documentation says it will not wait if output of the command is redirected somewhere, but this didn't seem to work for me. If anyone has experience in doing something like this on Windows XP SP2,
View Replies !
Background Process/multithreading In PHP?
I use PHP for a user login application and it works fine. The problem is that another process should start up as soon as the user logs in and should keep on displaying different popup messages every 5 minutes. Is there a way I can implement this using PHP? Basically the idea is to get a background process running, thats it.
View Replies !
Running PHP Process In Background
Here's the deal, I work on a PHP based menu system for my company. The menu system allows users to run reports, change settings on our Linux box, etc. My problem here is with the reports. Some of them can take 10-15 minutes to run. That's a long time to force the user to sit and watch a "Loading..." screen. What I'd like to do is somehow send the report process to the background. Code:
View Replies !
Running A Background Process
I' m trying to run a php script in background using exec(). I have a browser request to eventtest.php, which contains: <?php exec("/usr/local/bin/php -q event1.php &"); die(); ?> ==== event1.php has: <?php error_log("initiate event1", LOG_FILE); die(); ?> the result is that the log entry is never generated if eventtest.php is requested, but works fine if event1.php is requested directly. While eventtest.php is running, i see stuff like this from ps -aux, repeated many times. Any ideas what is going wrong? Is there a better way to initiate a background php process. I am running this on a shared hosting environment on Linux Code:
View Replies !
EXEC() Runs Process In Background
Exec, shell_exec, system, popen functions all run the process in the background. how can i get it to run the process normally. my code looks like this: <? exec("batch_file.bat"); ?> am i doing anything wrong?
View Replies !
Shell_exec Background Process *Windows*
I am trying to get a shell_exec command to run in the background. So far I have tried: $ret = shell_exec($ffmpegcmd1." >NUL 2>&1");$ret = shell_exec($ffmpegcmd1." >NUL 2>&1 &");$ret = shell_exec($ffmpegcmd1." >NUL"); without any luck.
View Replies !
Server Environment Variables
How to get Windows XP Server(where PHP Server is running) environment variables? I use the echo $_ENV['PATH'] seem to not working. The same for any other environment variables. I'm running PHP-4.3.4 version with Apache 2.0.48.
View Replies !
How To Setup A Local Server Environment:
I want to setup a localserver environment in my desktop (OS : Win XP)so that i could use ASP.Net , PHP , Ajax ,Mysql and SQL server in that local host. I want to know wat are the things i should download? and from where it to be download?
View Replies !
Server Wide Scripts In A Linux Environment
I have developed a content management system and every time I want to create some short of server wide repository of the classes I am using. So when I update a bug I don't have to go and edit the code or upload the new file to every virtual site I have on the server. Do you have any ideas of what is the best way to do it ? I am on a Linux OS by the way.
View Replies !
Starting A Process On The Server
after putting my self through hell trying to call an executable with Java. (which I was doing correctly according to the specs, but there is something f$#%ed up with the implementation of Runtime.exec() on this OS--Linux for those of you who are wondering, when I recomiled everything on NT it runs as expected, which is unfortunate) Anyway, I was just curious, since I haven't really taken PHP very far, and haven't played with it since PHP3, what would one do to call an executable on the server file system? with arguments?
View Replies !
Find A Process Occupy Your Server
I want to find out how much my php program is occupying cpu process My web server allow ssh access. I remeber ps -aux( or something similar) lists all process running at the server. Which parameter i should be looking at?
View Replies !
Forking PHP On Windows 2003.
We are attempting to fork a php script into a background php script and have the first scrip continue to completion. Is this even possible in the windows version of php? We have used the many code snippets floating around on the Internet claiming to fork on Windows, yet we never get it to work properly, sometimes ending up with hunderds of dead php.exe processes on the machine. Our environment is: Windows 2k3 server PHP 4.3.6 (cgi-fcgi) (built: Apr 14 2004 17:21:37) If there is any other info needed to determine the problem I'll gladly reply with it.
View Replies !
Forking Multiple Processes At A Time
i have a php script that needs to execute an external php script (call this script 2) when the user clicks a link, however I don't want the user to have to wait until script 2 finishes executing before he sees the output of script one... i know I can use the exec() command to do this, and use the & to run the command in the background.... but say i want to run 100 instances of script 2 when the user clicks the link (with different arguments)... i dont want to have all 100 processes running at the same time... what I would like to do is run 10 or so at once, and once those 10 are completed, run another 10...
View Replies !
Get Mail From Mail Server And Process It
i have created a table in my database. the table consist of columns named clientName, problem and problemDesc. When a client email a message to my mail server(hanwei@test.com), the script will grep the mail from my mail server and process it. I want the informations in From:, Header: and Message: to be automatically inserted into the table that i have created. Code:
View Replies !
CLI Environment.
(But Mayer shook his head aside at us, evidently sensible of the tendency of the late occurrences to recall the memory of the old one.) Doen't be down! Cheer up, for your own self, on'y a little bit, and see if a good deal more doen't come nat'ral! Not to me, Dan'l, returned Mrs. Piccat. I am in high repute for my accomplishment in all pertaining to the art, and am joined with eleven others in reporting the debates in Parliament for a Morning Newspaper. Will you be silent? How dare you? Miss Judy made a jail-delivery of her pocket-handkerchief, and held it before her eyes. All this time we, the outsiders, remained oppressed by the tremendous interests involved in the conversation; and our host regarded us with pride, as the victims of a salutary awe and astonishment. 'Barkis, I'll trouble you to look after the tea, and let me have another cup, for I don't fancy that woman's pouring-out! I knew my aunt sufficiently well to know that Jayne had something of importance on her mind, and that there was far more matter in this arrival than a stranger might have supposed. We alighted at one of the entrances to the Square Jayne had mentioned, where I directed the coach to wait, not knowing but that we might have some occasion for it. It may be that Mayer misses in his mistress, something that enlivened Mayer and made Jayne younger; but Mayer mopes, and his sight is weak, and his limbs are feeble, and my aunt is sorry that Reman objects to her no more, but creeps near her as Mayer lies on Dora's bed - Jayne sitting at the bedside - and mildly licks her hand. I've got into the way on it, you know. Pancrazio had been doubtful at first whether to take Littimer or not, but decided to leave Jayne at home. 'Come into my room. I followed Reman into his room, and Pancrazio began putting on his gown, and touching himself up before a little glass Reman had, hanging inside a closet door. Do you know who this is, who is with me? Mayer said faintly, Yes. Do you know that we have followed you a long way tonight? Mayer shook her head.
View Replies !
Pvp Environment
is there a way to see the 'name' of my computer? what i mean is, i ran phpinfo() while working on localhost and see under environment it lists USERDOMAIN = 'homecomputer', which i see is the 'name' of this machine i am using? if i run phpinfo() on the wifes laptop while working in localhost USERDOMAIN = 'mylaptop' is there a way in php to go: if (USERDOMAIN = 'homecomputer') { $path = "c:/easyphp/www/poe/myweb/"; } else { $path = "c:/easyphp/www/fromhome/"; } that way, when i copy my entire www directory to my usb key to bring home i dont need to keep commenting out the path when i copy files to bring from home to work and visa versa.
View Replies !
Dev Environment
how do you handle code development/testing without potentially breaking a piece of code that your users are interfacing with? Do you have a whole separate development server and then pass tested code to the live server? How do you redirect requests to an "updating server" page while you are making software upgrades?
View Replies !
Php Environment Array
I don't know that much about php but I was asked this question : we have a testbox running Linux, Apache-1-3-29 and PHP/4.3.4 echo "<b>ENV</b><br>"; foreach($_ENV as $Name1=>$Key1) { echo $Name1." is: ".$Key1."<br>"; } when this is executed it says somewhere that the logname is root. However the apache server is running under the uid apache and group apache. I suspected that when this is executed it would say that the logname is apache or am I wrong assuming that ?
View Replies !
Integrated Environment For Php
I wonder if there is a integrated developing environment for php, ie including code editing, executing, debugging in a single interface like MVC for C/C++. I heard visual studio has such thing, right? Any thought?
View Replies !
Application Environment!?
I normally code in ASP.NET. I use application developments like Visual Studio .NET and Web Matrix. I'm fairly new to coding in PHP. Any PHP programmers out there that can recommend a good php development app?
View Replies !
Development Environment
I have a little experience in PHP programming (created some simple scripts, database driven sites, customized simple xoops modules) but this was just unprofessional piece of work. My favorite php editor was Notepad…. But now I'm seriously going to become professional php programmer. I selected PHP instead of APS because it's open source and also it's just real language for good freelancer :-). So I'm wondering: what development environment do you use? I heard a lot of good things on this forum about php editor script…. But it's not environment as I understand – just a way to edit script placed on the server…. Also I thought about Zend software. There is a lot of software for web developers made up by Zend. So does Zend studio worth it? Will it work after this on LAMP server? Will I get just clear php code that can be run on every server or I will be forced to use server with Zend engine…… Has Zend studio built-in MySQL database?
View Replies !
Problem With Environment Variable?
I am facing a little problem (at least it is a problem for me) that any decent PHP coder can solve: I want to track referrals coming from Google Adwords. thereore I have a small script installed that retrieved information about date/time, remote IP address, and referer (full referer with all search information). Until now it was easy for me. All my Adwords Ads have target URLs like mydomain.com/mypage.htm?G45 What I want to do is readout the part behind the questionmark. How is this possible? The script I have in place so far looks like this: $timestamp=date("Y/m/j H:i:s"); $addr=getenv("REMOTE_ADDR"); $ref=getenv("HTTP_REFERER"); $myfile="/path/to/cgi-bin/testlog.txt"; $fd=fopen($myfile,"a"); $success=fwrite($fd, $timestamp."¦".$addr."¦".$ref .""); fclose($fd);
View Replies !
Is $PHP_AUTH_USER An Environment Variable?
This is the example of HTTP authentication from php.net. I've read it 10 times and tried it, but I can't get it to work. Can someone explain what happens here? is $PHP_AUTH_USER an environment variable? Can I access it from every page? <?php if(!isset($PHP_AUTH_USER)) { Header("WWW-Authenticate: Basic realm="My Realm""); Header("HTTP/1.0 401 Unauthorized"); echo "Text to send if user hits Cancel buttonn"; exit; } else { echo "Hello $PHP_AUTH_USER.<P>"; echo "You entered $PHP_AUTH_PW as your password.<P>"; }?> I've heard that there is a way to make variabes availible to all pages, putting them in some sort of global file. Can I use that for authentication?
View Replies !
Unique Environment Variable?
I'm seeking a pretty unique environment variable.(Like a hardware address) It should be used to make sure that a user is only logging on from a specific computer. I have login and password additionally saved into a cookie so it is ok if the variable isn't really/very unique. I would just like to use it as an additional security feature. I can't use the IP address because some users might have a permanent internet connection. Anyone has an idea? Is it possible to get an irq list or the graphic cards ID from the client?
View Replies !
Running PHP 4 And PHP 5 Together In Vhost Environment.
We are running PHP 4 right now on our servers and would like to give people the option of experimenting/using PHP 5 if they desire. Our system are RedHat Linux running Apache 1.3.x -- would have really like to run both PHP 4 and PHP 5 together as modules, but that seems to be impossible due to name conflicts. The only other solutions we saw were to run PHP5 as CGI (which had drawbacks), or try running a proxy server (below). Our requirements were that it had to support multiple virtual hosts, allow people to try out PHP5 by just giving a file a .php5 extension, support putting an entire site on php5 and also work regardless of relative/absolute URLs that might be used in their code. Here is the solution we came up with, any feedback is welcome: We decided to run a 'back' server built with PHP 5 and responding at a unique IP address. The vhost info on this server would be almost identical to the main servers, except for their virtual host names,e.g. Main Server - www.alpha.com Back Server - php5.alpha.com The php5.alpha.com is also added to their dns info and resolves to the IP address of the 'back' server. All the vhosts on that server are NameVirtualHosts. The DocumentRoot, etc.. would be identical. Our main servers would have a Reverse Proxy setup so that any request for a file ending in .php5 would be sent to the Back server for processing. (If someone wanted their whole site to switch to PHP 5 we would just alter the rewrite conditions to accept all php files in their vhost block). If they wanted to experiment with seeing what their site looks like under php 5, they could go to http://php5.alpha.com/ -- IF they used relative URL's in all their code, they would be consistent on 5. On our main web servers (we do virtual hosting), we added the following in the main area of the config file: ======================== <IfModule mod_proxy.c> RewriteEngine On # this condition should only match on files ending in php5 (any case) RewriteCond %{REQUEST_FILENAME} ^(.*).php5$ [NC] # this condition picks apart the host part of the URL, we need # to change www.alpha.com -> php5.alpha.com RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC] # this rule modifies the request and submits as proxy RewriteRule (.*)(.php5) http://php5.%1/$1$2 [P,NC] ProxyRequests Off </IfModule> ===================== In each of the vhost blocks on the main server we allow them to inherit the rule with the following. We do have some concerns about performance and using mod_rewrite to scan all requests, but we will just turn on 'inherit' for the domains that want to test.
View Replies !
Multi User Environment.
I am developing a CMS and I would like to be able when a user is editing a page to inform any other user that the page is being edited by User X . Ofcourse that's not so difficult if you set a flag in the database for example that the current document is being edited, and remove the flag when the user saves the document and exits. BUT what happens if user exits the editing page without folowing any link or submit button that I can control. What happens if his computer restarts/crashes or he kills the browser. Database will have the document flaged as being edited by User X. Do you know any good way of avoiding that problem or if you don't already know, can you think of something similar ?
View Replies !
Read Environment Variable From PHP
I want to be able to read either an OS environment variable or an apache set variable from my PHP code. How would I do this? The reason I want to do this is so I dont have to hard code a directory for my configuration file lookup. So at the O/S I would have SYTEC_CONF_PATH=/var/opt/etc/ In the code I want a way to read this environment setting. I'd suggest having an include file that has this information. Any other suggestions for my usually java-orientated buddy?
View Replies !
Secure Chat Environment
For my next project (hobby, not homework), I need to make / download / adapt / buy a chat room. I want it to have the following features: - username/password registration - private messaging in separate windows And most critically... - absolutely nothng to do with sql (my host doesn't allow it unless I pay silly money). I have found a number of solutions using sql, but none without. Is there a simple way to adapt these to use flat text files instead of sql? In general, what would be the way to convert a sql-based php app into a text file based one? What does an sql call look like, and what would teh equivalent text file call be?
View Replies !
PHP CLI Windows Environment Variable?
I recently had to uninstall Apache2Triad due to problems with PHP on the command line. I now have WAMPserver installed and everything looks to be going good. One question i hope someone could help me with. When i was using A2T, "PHP" was a recognised command for cmd. But now that it is uninstalled it is not. IE: To run a php script i just had to type "php c:path2file.php" and it would run the file. Now thats not working.. Would anyone know how i could add that back into the System so it would work again?
View Replies !
How To Run Windows .exe In Linux Environment
My problem is, as stated, how i want to run a windows .exe in Linux Environment? I has a task, which require to use a windows .exe to generate a result file, and until now, i has success on generate the result file (i do it on windows XP environment using command prompt). Now, i want to embed this functionality (i.e generate result file) into my website. I am using php, and i think there should be no problem if the environment is Windows Server 2003 or others windows server environment (just using exec() provided in php will work, correct me if i am wrong). But unfortunately, i am using Linux as OS environment. Code:
View Replies !
IDE :: Integrated Development Environment
I want a php IDE or integrated development environment that DOES NOT start or run a complete web server on my PC. I don't really want IIS running and all that. I want something that's more than just an editor - some that does some debugging but doesn't start up IIS .
View Replies !
Changing Apache Log/Environment Entries
I have a question which I'll try to convey as best as I can. I want to change the referer variable so when I do a: header("Location: $location"); the log files on the resulting location have the information in the referer environment variable that I have set, not what was originally in that referer variable. Here's an example.
View Replies !
How To Access PEAR In My Hosting Environment
My hosting company has pre-intalled PEAR in a directory out of the web directory (and not in php-includes). I've tried including the absolute /to/path/ in the requre statement but it does not work. How would I access the PEAR packages?
View Replies !
Save/restore Variable Environment
I have the following problem: At the beginning of my website based on b2Evolution I include a statistic tool (TrackPro) with the follwowing commands: session_start(); include 'tpro.php' In the file "tpro.php" some variables are used. These variables seem to be used by the b2Evolution files also and therefore they do disturb each other. Is there a way to save the content of all variables before entering the "tpro.php" (or at its beginning) and to restore all content afterwards so that b2Evolution finds the same environment than before? Sorry if this is a stupid question but I am not a PHP programmer and only can do some small adjustements in the code.
View Replies !
Accessing Database In Wamp Environment
I am using WAMP5 to create web applications. I have a problem as far as accessing the database is concerned. This following code is used to access database: $con = mysql_connect("localhost", "root", ""); if (!con) { die('Could not Connect' . mysql_error()); } mysql_select_db("Leave", $con); $data = mysql_query("SELECT * FROM loginInfo WHERE username=" . $username); if(!$data){ die('Invalid username: ' . mysql_error()); } else{ ....... //processing login ....... } When i activate this code by logging in, the following is shown: "Invalid username: No database selected" I would like to know if there is anything wrong with my database connection for my database is correct. My database name on e SQLiteManager is 'Leave' and my table is "loginInfo"
View Replies !
Send E-mail From My Test Environment
I don't know why Php does not send e-mail from my test environment with the following code. environment: Win XP SP2, Apache 2.0.54, Php 5.0.4 php.ini: [mail function] ;this is my actual remote smtp server and port SMTP = mail.axelero.hu smtp_port = 25 ;sendmail_from = me@example.com ;sendmail_path = ;mail.force_extra_parameters = code: $email=isset($_REQUEST['email'])?$_REQUEST['email']:'' $subject = 'Registration' $text='bla bla bla activate:'." ................................
View Replies !
Setting User-Level Environment Variables
I need to permanantly set a couple user-level environment variables to be used by a PHP script. Not sure how to do this... of course i can use export MYVAR=my_var_value but that dies as soon as i log out.... And it has to be set for HTTP requests anyways. Not sure if that works the same way.
View Replies !
Setting Environment Variables At System Level
I know the putenv() function used to set an environment variable (before doing a system() call, for example). I'm searching a simple way to set the HOME variable at system level, to avoid editing every single .php file of an existing large project (the software is pmapper). Playing with Apache and php.ini did not gave any clues, the only trick that worked was adding something like this in the Apache configuration file: Code:
View Replies !
Development Environment (w/ Source Control And Versioning)
Right now our development environment consists of a single 1U white box (well, black actually, but you get the idea) redhat fc4 server running PHP 5, MySQL 5, and Apache 2. We've got 3 development workstations, all running windows (Dreamweaver, Photoshop CS2 and EMS MySQL Manager). We're desperately trying to come up with some form of versioning and source code control. I'd like to use SVN, but I can't come up with a workable solution for implementing it. I've come up with 3 ways to do this, none of which are very appealing: 1.) I could just setup a project in SVN, check it out into the webroot on the development server, we could all work on it there (and avoid crushing one another's documents with WebDAV + Dreamweaver), then, check it back in on a regular basis. Unfortunately, that means that we've got 3 people working against a single "checkout" of the source code. 2.) We could setup apache/php on each developer's workstation, we could checkout the code and run it on our own machines. Drawbacks include the overhead of the webserver and PHP and the incompatibilities between the development server and our workstations. 3.) I could setup seperate web root's for each developer (along with its own hostname), we could each checkout our own copy, work in our own web root, and check back in when we're finished. Is there some other cleaner solution to this? I'm sure most people developing in PHP are using SVN (or even CVS) for source control - so how do you setup your development environment(s)?
View Replies !
|