shell脚本:关闭指定某个进程
#!/bin/bash
# 要查找的进程名
process_name="cccout"
# 查找名为 $process_name 的进程并关闭它
process_id=$(ps aux | grep -v grep | grep -m1 "$process_name" | awk '{print $2}')
if [ -z "$process_id" ]; then
echo "未找到正在运行的 $process_name 进程."
else
kill "$process_id"
echo "$process_name 进程 (PID: $process_id) 已成功关闭."
fi
英文打印
#!/bin/bash
# Process name to search for
process_name="cccout"
# Find and close the process named $process_name
process_id=$(ps aux | grep -v grep | grep -m1 "$process_name" | awk '{print $2}')
if [ -z "$process_id" ]; then
echo "No running process named $process_name found."
else
kill "$process_id"
echo "$process_name process (PID: $process_id) has been successfully terminated."
fi
原文地址:https://blog.csdn.net/mankeywang/article/details/137519896
免责声明:本站文章内容转载自网络资源,如侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!