情景描述:linux系統正運行着多個world進程,其pid保存在對應.pid文件中。該腳本 遍歷對應文件獲取pid,kill相應進程。
#!/bin/sh
for i in `seq 1 3`
do
pidfile_="worldd${i}.pid"
if [ -f ${pidfile_} ]; then
pid_=`cat ${pidfile_}`
rm -f ${pidfile_}
echo -n "killing worldd ${i}, pid ${pid_} .."
kill -9 ${pid_}
fi
done
echo "Done."
