note 107456 added to function.exec

From: Date: Fri, 10 Feb 2012 13:24:43 +0000
Subject: note 107456 added to function.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-186050@lists.php.net to get a copy of this message
As already noted by others, to background a single command on Linux append the & symbol. For a sequence of commands, enclose them within parentheses then append the & symbol but be sure to redirect stdout, stderr somewhere otherwise your script will hang waiting e.g.: <?php exec('( sleep 10; echo "finished" | mail ian@example.com ) &> /dev/null &'); ?> Usually you would put the commands in a shell script and call that from exec, however the above trick will help where the sequence is dynamically generated from php. Credit to http://stackoverflow.com/a/3750028 for the idea. ---- Server IP: 69.147.83.197 Probable Submitter: 202.89.170.110 ---- Manual Page -- http://www.php.net/manual/en/function.exec.php Edit -- https://master.php.net/note/edit/107456 Del: integrated -- https://master.php.net/note/delete/107456/integrated Del: useless -- https://master.php.net/note/delete/107456/useless Del: bad code -- https://master.php.net/note/delete/107456/bad+code Del: spam -- https://master.php.net/note/delete/107456/spam Del: non-english -- https://master.php.net/note/delete/107456/non-english Del: in docs -- https://master.php.net/note/delete/107456/in+docs Del: other reasons-- https://master.php.net/note/delete/107456 Reject -- https://master.php.net/note/reject/107456 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186050) next »