How can I delete all not used semaphores and shared memory with a single command on a UNIX-like system, e.g., Ubuntu?
Access the MEMORY application menu as described in Accessing KM Commands and InfoBoxes. Select Remove Semaphores. BMC PATROL displays the Remove Semaphores dialog box. Type the numeric ID in the Semaphore ID field and click either Apply or Apply To Selected.
Semaphores let processes query or alter status information. They are often used to monitor and control the availability of system resources such as shared memory segments. Semaphores can be operated on as individual units or as elements in a set.
The semaphore is a system for synchronization 2 or plus process to access a shared resource. The shared memory is a system for sharing a piece of memory between 2 o plus process, on the shared memory is possible write or read data to and from a process.
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
We use it whenever we run IPCS programs in the university student server. Some people don't always cleanup so...it's needed :P
This works on my Mac OS:
for n in `ipcs -b -m | egrep ^m | awk '{ print $2; }'`; do ipcrm -m $n; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With