Use the kill command to terminate the process shell script

Because some programs use to kill off the end of the process, the script is not closed to our services, for example, the service called asset-server service, only startup script, written from closed script, and restart the script.

Close service script.

vim asset-shutdown

#!/bin/bash
for assetstatus in "`ps -ef | grep asset-server | awk '{print $2}'| sed -n '1'p`"
do
kill -9 $assetstaus;
echo "asset shutdown [ok]"
done

Restart service script

vim  asset-restart

#!/bin/bash
for assetsuid in "`ps -ef | grep asset-server | awk '{print $2}'| sed -n '1'p`"
do
kill -9 $assetsuid;
echo $?>>/dev/null
done

if [ $? -lt 1 ]
then
nohup  ./asset-server

echo "Restart Completion"
fi

Guess you like

Origin www.cnblogs.com/sxshaolong/p/11016355.html