note 70135 added to ref.exec

From: Date: Wed, 04 Oct 2006 17:38:18 +0000
Subject: note 70135 added to ref.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-118036@lists.php.net to get a copy of this message
Here's a function to launch a low-priority background process very simply, returning control to the foreground. I found that a lot of the other approaches shown here allow the script to continue running, and the page is served up to the user, but the PHP thread that launched the process cannot be re-used until the process has completed. Stdout and stderr need to be redirected to /dev/null to prevent this. This is for BSD/*NIX servers only (tested on Fedora Core and OSX). Win32 approaches would be necessarily very different. Omit 'nice' if you don't want to run the process with lowered priority. <?php function fork($shellCmd) { exec("nice $shellCmd > /dev/null 2>&1 &"); } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 68.84.253.146 ---- Manual Page -- http://www.php.net/manual/en/ref.exec.php Edit -- https://master.php.net/note/edit/70135 Del: integrated -- https://master.php.net/note/delete/70135/integrated Del: useless -- https://master.php.net/note/delete/70135/useless Del: bad code -- https://master.php.net/note/delete/70135/bad+code Del: spam -- https://master.php.net/note/delete/70135/spam Del: non-english -- https://master.php.net/note/delete/70135/non-english Del: in docs -- https://master.php.net/note/delete/70135/in+docs Del: other reasons-- https://master.php.net/note/delete/70135 Reject -- https://master.php.net/note/reject/70135 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#118036) next »