note 38451 added to function.exec

From: Date: Mon, 22 Dec 2003 06:30:41 +0000
Subject: note 38451 added to function.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-62307@lists.php.net to get a copy of this message
In order to execute a command have have it not hang your php script while it runs, the program you run must not output back to php. To do this, redirect both stdout and stderr to /dev/null, then background it. > /dev/null 2>&1 & In order to execute a command and have it spawned off as another process that is not dependent on the apache thread to keep running (will not die if somebody cancels the page) run this: exec('bash -c "exec nohup setsid your_command > /dev/null 2>&1 &"'); ---- Manual Page -- http://www.php.net/manual/en/function.exec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38451 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38451&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38451&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62307) next »