使用php杀死Linux中的用户进程
我正在尝试编写一个 php 脚本来杀死 redhat 机器中的用户。
我知道有可能(而且非常不安全)让apache能够以root身份执行操作,但我需要能够从网页上杀死任何用户,是否有人有任何好的工作脚本或给我指出一个地方找到更多信息吗?我可以使用这段代码(我从 php.net 获取)来使其工作,但我认为只有当我授予 apache root 权限或以 root 身份运行 apache 时,这才有效。
<?php
exec("kill -9 $pid");
?>
这个命令会提取用户及其进程 ID,我认为一旦解决了 apache 问题,它就可以很好地获取用户列表以供我输出。
who -u | awk '{print $1" "$7}'
我实在想不出任何其他可以提供的信息,所以如果我忘记了什么,请告诉我。
I am trying to write a php script to kill users in a redhat machine.
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");
?>
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请改用 skill 命令:
Use the skill command instead: