删除类似UNIX的系统上的所有SYSTEM V共享内存和信号灯 [英] Delete all SYSTEM V shared memory and semaphores on UNIX-like systems

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

问题描述

如何在类似UNIX的系统(例如Ubuntu)上用单个命令删除所有未使用的信号灯和共享内存?

How can I delete all not used semaphores and shared memory with a single command on a UNIX-like system, e.g., 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

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

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