在确认“$ service”是“httpd”之后,您将使用以下脚本,例如:
if [ "$service" != "httpd" ]; then
exit 1;
fi
/etc/cron.hourly/ipcs_check
内容:
#!/bin/sh
EMAIL=your@email.com
MAX_SEMAPHORES=15
IPCS=/usr/bin/ipcs
IPCRM=/usr/bin/ipcrm
MAIL=/bin/mail
COUNT=`${IPCS} | grep apache | wc -l`
if [ "$COUNT" -le $MAX_SEMAPHORES ]; then
#all is well, there are no semaphore build-ups.
exit 0;
fi
#we have more than MAX_SEMAPHORES, so clear them out and restart Apache.
LIST=/root/sem.txt
${IPCS} | grep apache | awk '{print $2}' > ${LIST}
for i in `cat ${LIST}`; do
{
${IPCRM} -s $i;
};
done;
/etc/init.d/httpd restart
TXT="${COUNT} semaphores cleared for apache for `hostname`"
echo "${TXT}" | ${MAIL} -s "${TXT}" ${EMAIL}
exit 1;
chmod 755 /etc/cron.hourly/ipcs_check








