用php杀死linux中的用户进程 [英] kill users processes in linux with php

查看:29
本文介绍了用php杀死linux中的用户进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 php 脚本来杀死 redhat 机器中的用户.

I am trying to write a php script to kill users in a redhat machine.

我知道有可能(并且非常不安全)让 apache 能够以 root 身份执行任务,但是我需要能够从网页中杀死任何用户,有没有人有任何好的工作脚本或指向我一个可以找到更多信息的地方?我可以使用此代码(我从 php.net 中获取)使其工作,但我认为这仅在我授予 apache root 权限或以 root 身份运行 apache 时才有效.

I know it is possible (and very insecure) to give apache the ability to do things as root, but I need to be able to kill any user from a web page, does anyone have any good working scripts or point me to a place to find some more info? I can use this code (which I took from php.net) to make it work, but I assume that this will work only if I give apache root permission or run apache as root.

<?php
    exec("kill -9 $pid");
?>

这个命令会拉取用户和他们的进程 id,我认为一旦发现 apache 问题,它就可以很好地获取用户列表供我输出.

This command pulls the user and their process id which I assume once the apache issue is figured out will work just fine for grabbing the list of users for me to output.

who -u | awk '{print $1" "$7}'

我实在想不出我可以提供的任何其他信息,所以如果我忘记了什么,请告诉我.

I can't really think of any other info I can give on this, so let me know if I am forgetting anything.

推荐答案

使用 skill 命令代替:

skill -9 -u username

这篇关于用php杀死linux中的用户进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆