0

I'm allocating some shared Memories and Message Queues with specific perm "644".

Removing them manually is a hard work so I want to know how can I remove all the rows with that specific perm 644.

e.g

------ Shared Memory Segments -------- key shmid owner perms bytes nattch status
0x00000000 0 benny 600 33554432 2 dest
0x00000000 229377 benny 644 52 0

------ Semaphore Arrays -------- key semid owner perms nsems

------ Message Queues -------- key msqid owner perms used-bytes messages
0x2731af4c 262144 benny 644 840 30
0x0756d9c1 294913 benny 644 16380 585
0x2d1b2cc7 327682 benny 644 0 0
0x343dccc1 360451 benny 644 0 0

Thanks.

2 Answers2

0

You have to use a script to do it e.g.

#!/bin/bash

m=`ipcs -m | grep -w 644 | cut -d' ' -f2`
for i in $m
do
        echo removing shm id $i
        ipcrm -m $i
done

s=`ipcs -s | grep -w 644 | cut -d' ' -f2`
for i in $s
do
        echo removing sem id $i
        ipcrm -s $i
done

q=`ipcs -q | grep -w 644 | cut -d' ' -f2`
for i in $q
do
        echo removing queue id $i
        ipcrm -q $i
done
parkydr
  • 7,596
  • 3
  • 32
  • 42
0
ipcs -a | awk '{ \
  if ($3=="Memory")    ARG="-m"; \
  if ($3=="Semaphore") ARG="-s"; \
  if ($3=="Message")   ARG="-m"; \
  if ($4=="644")      system ("ipcrm "ARG" "$2""); \
  }'