ipcs - show information on IPC facilities.

IPC - 进程间通信(Inter-Process Communication)。

一、ipcs

ipcs是linux/uinx上提供关于一些进程间通信方式信息的命令,包括共享内存,消息队列,信号。

ipcs参数说明

snippet.bash
[ff@test ff]$ ipcs -u
 
------ Messages Status --------
allocated queues = 0
used headers = 0
used space = 0 bytes
 
------ Shared Memory Status --------
segments allocated 52
pages allocated 23105
pages resident  22354
pages swapped   0
Swap performance: 0 attempts	 0 successes
 
------ Semaphore Status --------
used arrays = 148
allocated semaphores = 2500
snippet.bash
[ff@test ff]$ ipcs -l
 
------ Messages Limits --------
max queues system wide = 2048
max size of message (bytes) = 65536
default max size of queue (bytes) = 65536
 
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 131926556
max total shared memory (kbytes) = 131926556
min seg size (bytes) = 1
 
------ Semaphore Limits --------
max number of arrays = 4096
max semaphores per array = 500
max semaphores system wide = 2048000
max ops per semop call = 200
semaphore max value = 32767

二、ipcrm

移除一个消息对象。或者共享内存段,或者一个信号集,同时会将与ipc对象相关链的数据也一起移除。当然,只有超级管理员,或者ipc对象的创建者才有这项权利。

ipcrm参数说明

三、ipcs -m

查询所有共享内存

ipcs -m

释放所有共享内存

ipcs -m | awk '$2 ~ /[0-9]+/ {print $2}' | while read s; do sudo ipcrm -m $s; done

释放指定用户的所有共享内存

ipcs -m | grep user_name | awk '$2 ~ /[0-9]+/ {print $2}' | while read s; do sudo ipcrm -m $s; done

四、参考