1. 程式人生 > >linux啟動程式和關閉程式指令碼

linux啟動程式和關閉程式指令碼

關閉指令碼:

#!/bin/bash
source /etc/profile
log()
{
echo `date +【%Y-%m-%d" "%H:%M:%S】` $1
}
log "kill 168 begain"
NAME=importFile168
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
log "kill 168 end"

 

啟動指令碼:

#!/bin/bash
source /etc/profile
log()
{
echo `date +【%Y-%m-%d" "%H:%M:%S】` $1
}
log "start 168 begain"
nohup /home/data/168/program/jdk1.8.0_111/bin/java -Drun.type=loaddata -ms512m -mx1024m -jar /home/data/168/program/importFile168.jar >> /home/data/168/program/168.log 2>&1 &
log "start 168 end"