kill users processes in linux with php

别说谁变了你拦得住时间么 提交于 2020-01-11 13:35:09

问题


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.


回答1:


Use the skill command instead:

skill -9 -u username


来源:https://stackoverflow.com/questions/6308774/kill-users-processes-in-linux-with-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!