- 列出该用户正在运行的进程。
- 在终止进程之前与系统管理员确认。
- 确认后杀死进程。
答案1
要列出所有正在运行的进程,请使用ps
:
ps –aux (list all process)
ps –aux |grep processName
top (something like task manager) (don’t use it with scripting)
杀死任何进程:
kill -9 processNumber
作为脚本:
#!/bin/bash
while [ true ]
ps -aux
do
echo "enter the processNum you want to kill?"
read num
echo "Are you sure you want to kill $num?"
echo "write 1 if yes"
echo "write 2 if No "
read choice
if [ $choice -eq 1 ]
then
kill -9 $num
fi
done