This is a discussion on Info on background process in PHP within the PHP Programming forums, part of the Web Development category; Hi, Running a background process in PHP In an ideal world, all of the functions that you need would be ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, Running a background process in PHP In an ideal world, all of the functions that you need would be available in the language of your choice. This is rarely the case for bioinformatics projects, where it’s often convenient or necessary to run a script or program outside your main script, grab the results and parse them. Easy enough - but if you’re writing a web application and the external program takes longer than a few seconds to run, you’re faced with a blank web page and confused users. Normally, the page loads only after all associated processes are complete. So you’d like to run your external program in the background and display a reassuring message that says “Analysing sequence. . .”, or something similar. Here’s how you do that in PHP. The PHP function that you need is shell_exec(). PHP has excellent online documentation: here’s the shell_exec() entry. A kind user has provided us with 2 functions for use under Linux: one for running a background process, another for monitoring a running process. I’ve edited them slightly and present them below: function run_in_background($Command, $Priority = 0) { if($Priority) $PID = shell_exec("nohup nice -n $Priority $Command 2> /dev/null & echo $!"); else $PID = shell_exec("nohup $Command 2> /dev/null & echo $!"); return($PID); } function is_process_running($PID) { exec("ps $PID", $ProcessState); return(count($ProcessState) >= 2); } Regards, sivaraman. |
| Sponsored Links |
| |||
| Hi shiva, The path /home/php/bin/php is the php installed path , it is not related with the enabling background process because it is inbuild with linux os, only we have to check shell_exec function is enabled or not , it is easily verified in the php configuration file safe_mode_exec_dir directive Regards, Vivekanandan |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| To change the BackGround Color of Submenus without using CSS | kingmaker | HTML, CSS and Javascript Coding Techniques | 1 | 01-20-2008 09:20 PM |
| Desktop Background Problem | it.wily | Operating Systems | 13 | 01-10-2008 09:34 PM |
| Relation between process system time, process waiting time | vigneshgets | Operating Systems | 0 | 08-01-2007 12:57 AM |
| Background Music in html | Arun | HTML, CSS and Javascript Coding Techniques | 2 | 07-13-2007 01:49 AM |
| Background Check Search | allenhan | Advertising Sales and Affiliate Programs | 0 | 06-28-2007 06:47 PM |