删除Linux上的所有共享内存和信号灯 [英] Delete all shared memory and semaphores on Linux

查看:1186
本文介绍了删除Linux上的所有共享内存和信号灯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能删除所有未使用信号量和共享内存在Ubuntu一个命令?

How can I delete all not used semaphores and shared memory with a single command in Ubuntu?

推荐答案

下面,保存并在你的shell试试这个脚本(kill_ipcs.sh):

Here, save and try this script (kill_ipcs.sh) on your shell:

#!/bin/bash

ME=`whoami`

IPCS_S=`ipcs -s | egrep "0x[0-9a-f]+ [0-9]+" | grep $ME | cut -f2 -d" "`
IPCS_M=`ipcs -m | egrep "0x[0-9a-f]+ [0-9]+" | grep $ME | cut -f2 -d" "`
IPCS_Q=`ipcs -q | egrep "0x[0-9a-f]+ [0-9]+" | grep $ME | cut -f2 -d" "`


for id in $IPCS_M; do
  ipcrm -m $id;
done

for id in $IPCS_S; do
  ipcrm -s $id;
done

for id in $IPCS_Q; do
  ipcrm -q $id;
done

我们使用它时,我们运行大学生服务器IPCS程序。有些人总是不清理所以...它的需要:P

We use it whenever we run IPCS programs in the university student server. Some people don't always cleanup so...it's needed :P

这篇关于删除Linux上的所有共享内存和信号灯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆