强大的php函数shell_exec
来源:互联网 发布:mysql查看锁状态 编辑:程序博客网 时间:2024/05/25 01:36
一个实现杀死服务器所有进程的类!
<?php
/**
* PHP Kill Process
*
* Sometimes, it can happen a script keeps running when it shouldn't, and it
* won't stop after we close the browser, or shutdown the computer. Because it's
* not always easy to use SSH there's a workaround.
*
* @author Jensen Somers <php@jsomers.be>
* @version 1.0
*/
class KillAllProcesses {
/**
* Construct the class
*/
function killallprocesses() {
$this->listItems();
}
/**
* List all the items
*/
function listItems() {
/*
* PS Unix command to report process status
* -x Select processes without controlling ttys
*
* Output will look like:
* 16479 pts/13 S 0:00 -bash
* 21944 pts/13 R 0:00 ps -x
*
*/
$output = shell_exec('ps -x');
$this->output($output);
// Put each individual line into an array
$array = explode("\n",$output);
$this->doKill($array);
}
/**
* Print the process list
* @param string $output
*/
function output($output) {
print "<pre>".$output."</pre>";
}
/**
* Kill all the processes
* It should be possible to filter in this, but I won't do it now.
* @param array $array
*/
function doKill($array) {
/*
* Because the first line of our $output will look like
* PID TTY STAT TIME COMMAND
* we'll skip this one.
*/
for ($i = 1;$i < count($array);$i++) {
$id = substr($array[$i],0, strpos($array[$i],' ?'));
shell_exec('kill '.$id);
}
}
}
new KillAllProcesses();
?>
- 强大的php函数shell_exec
- PHP中exec与shell_exec函数区别
- PHP Shell_exec所遇到的坑
- 解决Windows下PHP的exec、shell_exec等函数不能正常运行的方法
- PHP执行Linux命令的两个有用的函数exec和shell_exec
- php执行外部命令函数:exec()、passthru()、system()、shell_exec()对比
- PHP执行系统外部命令函数:exec()、passthru()、system()、shell_exec()
- PHP执行系统外部命令函数:exec()、passthru()、system()、shell_exec()
- php shell_exec vs shell
- PHP中强大的过滤验证函数
- 强大的PHP生成缩略图函数
- 强大的PHP生成缩略图函数。
- 强大的PHP生成缩略图函数
- 概述PHP命令行shell_exec()使用
- 玩转PHP(二)--PHP强大的时间函数:date()
- exec 与shell_exec的区别
- php中exec, shell_exec,system, passthru在执行shell时候的区别
- No such file or directory; did you install phantomjs? php shell_exec报错的解决
- Linux下常用命令
- 布局管理器——绝对布局
- 实现tomcat启动时自动运行代码
- 关于push与unshift的区别与比较
- 数据库的相关概念
- 强大的php函数shell_exec
- 欢迎使用CSDN-markdown编辑器
- 登陆MySQL数据库,以及常用操作命令
- Hadoop技术梗概(一)
- 欢迎使用CSDN-markdown编辑器
- 指针和引用的区别
- bzoj 1007: [HNOI2008]水平可见直线
- Android 6.0蓝牙权限问题
- 初玩linux epoll------一个服务器如何与多个客户端进行通信? (笔试面试常考)