note 59898 added to function.shell-exec
| From: | AshrafKaabi at osu1 dot php dot net | Date: | Mon, 19 Dec 2005 18:06:39 +0000 |
| Subject: | note 59898 added to function.shell-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100420@lists.php.net to get a copy of this message | ||
I've write a Full Class for Run in Background, Kill PID , check if is Running
<?php
/**
* @author Ashraf M Kaabi
* @name Advance Linux Exec
*/
class exec {
/**
* Run Application in background
*
* @param unknown_type $Command
* @param unknown_type $Priority
* @return PID
*/
function background($Command, $Priority = 0){
if($Priority)
$PID = shell_exec("nohup nice -n $Priority $Command > /dev/null & echo
$!");
else
$PID = shell_exec("nohup $Command > /dev/null & echo $!");
return($PID);
}
/**
* Check if the Application running !
*
* @param unknown_type $PID
* @return boolen
*/
function is_running($PID){
exec("ps $PID", $ProcessState);
return(count($ProcessState) >= 2);
}
/**
* Kill Application PID
*
* @param unknown_type $PID
* @return boolen
*/
function kill($PID){
if(exec::is_running($PID)){
exec("kill -KILL $PID");
return true;
}else return false;
}
};
?>
----
Manual Page -- http://www.php.net/manual/en/function.shell-exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59898
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59898&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59898&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59898&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59898&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59898&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59898&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59898&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59898&report=yes
Search -- http://master.php.net/manage/user-notes.php