i have a couple of servers that are changing perms on /dev/null so that "other" can't access it, at random (well, i'm sure SOMETHING'S causing it, but the timing is random), so i wrote a script to go in the inittab so it'll respawn if it dies (bash shell)
the script exports different variables, such as the mail recipient, gets the servername from a hostname -s (unless that's null, and then it gets it from some other places), and then simply loops:
i=1
while [ "$i" -lt "2" ]
do
export MINUTE=`date +%M`
if [ "$MINUTE" = "58" ]
then
#echo "minute is $MINUTE. going to exit, should respawn" >/tmp/minute.txt
sleep 50
exit 0
fi
export MODE=`stat /dev/null | grep Access | head -1 | awk -F\( '{print $2}' | awk -F/ '{print $1}'`
if [ "$MODE" = "0660" ]
then
echo "Changing /dev/null to global rw at `date`"
/bin/chmod 666 /dev/null
echo "done"
echo "$SERVER: had to reset permissions on /dev/null at `date`" > $MAIL_FILE
send_mail;
sleep $SLEEP
i=1
fi
done
where send_mail is just another function to send mail if the mail recipient is defined.
the problem is that this thing is driving the load up to 3 and taking 12% of the cpu, and consistently shows as the top value in top -S
this isn't showing up to the end-user perspective yet, but since one server is a sql db server and the other is a web server, i'm sure that at some point the degradation will creep in.
does anyone have any suggestions
a) as to why the load is driving so high
b) possibly an easy way around it?
if i know the "why" i can probably fix something up.
it sleeps only for 10 seconds. i thought about having it check to see if "file a" exists before starting, but then it'd overspawn from the inittab and flood /var/log/messages i think...
thanks!