shell脚本,定时kill掉程序

#!/bin/bash
time_end=$(date '+%s' -d '3 minutes')
echo "time_end =" $time_end
while true
do
sleep 2
time_temp=$(date '+%s')
echo "time_temp =" $time_temp
if [ $time_temp -gt $time_end ];then
    echo "performance end 1111"
    su -c "ps -ef | grep jmeter | grep -v grep | cut -c 9-15 | xargs kill -s 9"
    echo "kill jmeter 2222"
    break 2
elif [ $time_temp -eq $time_end ];then
    echo "performance end 3333"
    su -c "ps -ef | grep jmeter | grep -v grep | cut -c 9-15 | xargs kill -s 9"
    echo "kill jmeter 4444"
    break 2
else
    echo "performance continue"

fi

猜你喜欢

转载自km-moon11.iteye.com/blog/2338056