Cleaning hanging IPCS in UNIX

Tag: unix Author: totorowei Date: 2009-10-20

I knew that IPCRM is used to clean hanging IPCS and semaphores for a particumar user by passing the segment id or the semaphore id in either -m or -s option. WE NEED TO PASS INDIVIDUAL SEGMENT ID/ SEMAPHORE ID IN -m OPTION. Is there any way to clean ipcs that belongs to a particular user in just one move.

I think shell script could be the way but not sure.

Other Answer1

Give something like this a try:

ipcs -s | awk '$1=="s" && $5=="daveshawley" {print "-s",$2}' | xargs ipcrm

You will probably want to substitute the user's real name for mine of course. You might want to try this question over on http://superuser.com as well