【ubuntu24.04】pycharm 死机结束进程

windows 远程pycharm到ubuntu执行程序

  • pycharm 在调试过程中,内存耗尽,然后死机了

pycharm 进程

bash 复制代码
(base) root@k8s-master-pfsrv:/home/zhangbin/下载# ps -ef | grep pycharm
root      121245 3230568  0 5月14 pts/8   00:00:00 /bin/bash --rcfile /root/.cache/JetBrains/RemoteDev/dist/b0c1870a0e7bc_pycharm-professional-242.21829.44/plugins/terminal/shell-integrations/bash/bash-integration.bash -i
root      121246 3230568  0 5月14 pts/9   00:00:00 /bin/bash --rcfile /root/.cache/JetBrains/RemoteDev/dist/b0c1870a0e7bc_pycharm-professional-242.21829.44/plugins/terminal/shell-integrations/bash/bash-integration.bash -i
root      884268 2292779  0 5月15 pts/10  00:00:00 /bin/bash --rcfile /root/.cache/JetBrains/RemoteDev/dist/a63ecb49ae401_pycharm-professional-2024.3.5/plugins/terminal/shell-integrations/bash/bash-integration.bash -i
root     2292766       1  0 5月12 ?       00:00:00 /bin/sh /root/.cache/JetBrains/RemoteDev/dist/a63ecb49ae401_pycharm-professional-2024.3.5/bin/remote-dev-server.sh run /home/zhangbin/perfwork/01_ai/12_exp_v1.2
root     2292779 2292766 11 5月12 ?       17:28:12 /root/.cache/JetBrains/RemoteDev/dist/a63ecb49ae401_pycharm-professional-2024.3.5/bin/remote-dev-server run /home/zhangbin/perfwork/01_ai/12_exp_v1.2
root     2292869 2292779  0 5月12 ?       00:00:16 /root/.cache/JetBrains/RemoteDev/dist/a63ecb49ae401_pycharm-professional-2024.3.5/bin/fsnotifier
root     2387852 2292779  0 5月12 pts/1   00:00:00 /bin/bash --rcfile /root/.cache/JetBrains/RemoteDev/dist/a63ecb49ae401_pycharm-professional-2024.3.5/plugins/terminal/shell-integrations/bash/bash-integration.bash -i
root     2387853 2292779  0 5月12 pts/0   00:00:00 /bin/bash --rcfile /root/.cache/JetBrains/RemoteDev/dist/a63ecb49ae401_pycharm-professional-2024.3.5/plugins/terminal/shell-integrations/bash/bash-integration.bash -i
root     3108391 2292779  0 5月13 pts/5   00:00:00 /bin/bash --rcfile /root/.cache/JetBrains/RemoteDev/dist/a63ecb49ae401_pycharm-professional-2024.3.5/plugins/terminal/shell-integrations/bash/bash-integration.bash -i
root     3108393 2292779  0 5月13 pts/6   00:00:00 /bin/bash --rcfile /root/.cache/JetBrains/RemoteDev/dist/a63ecb49ae401_pycharm-professional-2024.3.5/plugins/terminal/shell-integrations/bash/bash-integration.bash -i
root     3230555       1  0 5月13 ?       00:00:00 /bin/sh /root/.cache/JetBrains/RemoteDev/dist/b0c1870a0e7bc_pycharm-professional-242.21829.44/bin/remote-dev-server.sh run /home/zhangbin/perfwork/01_ai/01_semantic-text2image-search
root     3230568 3230555  4 5月13 ?       05:48:54 /root/.cache/JetBrains/RemoteDev/dist/b0c1870a0e7bc_pycharm-professional-242.21829.44/bin/remote-dev-server run /home/zhangbin/perfwork/01_ai/01_semantic-text2image-search
root     3230654 3230568  0 5月13 ?       00:00:12 /root/.cache/JetBrains/RemoteDev/dist/b0c1870a0e7bc_pycharm-professional-242.21829.44/bin/fsnotifier
root     3707660  534637  0 16:27 pts/3    00:00:00 grep --color=auto pycharm

一键kill

bash 复制代码
(base) root@k8s-master-pfsrv:/home/zhangbin/下载# ps -ef | grep pycharm | grep -v grep | awk '{print $2}' | xargs kill -9
(base) root@k8s-master-pfsrv:/home/zhangbin/下载# ps -ef | grep pycharm
root     3708702  534637  0 16:28 pts/3    00:00:00 grep --color=auto pycharm
(base) root@k8s-master-pfsrv:/home/zhangbin/下载# 

脚本

bash 复制代码
#!/bin/bash

# 获取所有PyCharm相关进程的PID(除了grep自己)
PIDS=$(ps -ef | grep pycharm | grep -v grep | awk '{print $2}')

# 显示将要终止的进程
echo "将要终止以下进程:"
ps -f $PIDS

# 先尝试正常终止
echo "正在尝试正常终止进程..."
for pid in $PIDS; do
    echo "终止进程 $pid"
    kill $pid
done

# 等待3秒,看是否有进程自行终止
sleep 3

# 检查是否还有进程存在
REMAINING_PIDS=$(ps -p $PIDS -o pid= 2>/dev/null)
if [ -n "$REMAINING_PIDS" ]; then
    echo "以下进程没有响应,将强制终止:"
    ps -f $REMAINING_PIDS
    
    for pid in $REMAINING_PIDS; do
        echo "强制终止进程 $pid"
        kill -9 $pid
    done
fi

# 最后确认
sleep 1
if ps -p $PIDS >/dev/null 2>&1; then
    echo "警告:仍有一些进程未能终止"
else
    echo "所有PyCharm相关进程已经终止"
fi
相关推荐
Python×CATIA工业智造20 分钟前
Python数据汇总与统计完全指南:从基础到高阶实战
python·pycharm
-KamMinG1 小时前
分享:一键自动化巡检服务器
服务器·chrome·自动化
许商2 小时前
【stm32】cmake构建vscode开发环境
ide·vscode·编辑器
小-黯6 小时前
VSCode+QT开发环境配置
ide·vscode·qt
xcs194056 小时前
前端 开发vscode trae idea 热键
ide·vscode·intellij-idea
没头脑的男大9 小时前
jupyter notebook继续学习
ide·学习·jupyter
Xiaok101816 小时前
Jupyter Notebook 两种模式:编辑模式 & 命令模式
ide·jupyter·命令模式
玩转C语言和数据结构1 天前
Jupyter Notebook下载安装使用教程(附安装包,图文并茂)
ide·python·jupyter·anaconda·jupyternotebook·anaconda下载·anaconda安装包
^Lim1 天前
ubuntu编译freerype报错找不到libfreetype.la
linux·chrome·ubuntu
qiqiqi(^_×)1 天前
解决linux‘打开readme.md文件pycharm闪退’问题
linux·运维·pycharm