|
Directory : /scripts2/ |
#! /bin/bash
echo Current count of nobody semaphores:
ipcs -s |grep nobody |wc -l
# List ID numbers of the semaphores
echo Semaphore IDs are as follows:
nobodysemaphoreIDs=`ipcs -s |grep nobody| awk '{print $2}'`
echo ${nobodysemaphoreIDs}
# Check how many nobody shared memory segments exist
echo Current count of nobody shared memory segments:
ipcs -m |grep nobody|wc -l
# List ID numbers of the shared memory segments
echo Shared Memory Segment IDs are as follows:
nobodymemoryIDs=`ipcs -m |grep nobody| awk '{print $2}'`
echo ${nobodymemoryIDs}
#If semaphores owned by nobody exist, then remove them
if [ ! -z "$nobodysemaphoreIDs" ]
then
echo Now removing nobody semaphores
for i in ${nobodysemaphoreIDs}
do
ipcrm -s $i
done
echo Finished cleanup of nobody semaphores
else
echo There are no semaphores owned by nobody
fi
#If shared memory segments owned by nobody exist, then remove them
if [ ! -z "$nobodymemoryIDs" ]
then
echo Now removing nobody shared memory segments
for i in ${nobodymemoryIDs}
do
ipcrm -m $i
done
echo Finished cleanup of nobody shared memory segments
else
echo There are no shared memory segments owned by nobody
fi
exit 0