请使用shell语言编写一个杀死进程的脚本
#!/bin/bash
提示用户输入进程名
read -p "请输入要杀死的进程名: " process_name
查找进程ID
pid=$(ps -ef | grep $process_name | grep -v grep | awk '{print $2}')
杀死进程
if [ -z "$pid" ]; then echo "未找到名为 $process_name 的进程" else echo "找到进程 $process_name,进程ID为 $pid" kill $pid echo "进程 $process_name 已被杀死" fi
原文地址: https://www.cveoy.top/t/topic/hVHs 著作权归作者所有。请勿转载和采集!