- stop
#!/bin/bash
port=9001
pid="$(netstat -ntpl | grep $port | awk '{print $7}' | awk -F '/' '{print $1}')"
kill -9 $pid
- start
#!/bin/bash
logFilePath="main.log"
if [ -f "$logFilePath" ]; then
createTime="$(stat $logFilePath | grep Access | tail -n 1 | awk '{print $2, $3}')"
createTimeStr="$(date -d "$createTime" '+%Y%m%d%H%M')"
cp $logFilePath logsbak/main-$createTimeStr.log
rm -rf $logFilePath
fi
nohup java -Djava.security.egd=file:/dev/./urandom -Dfile.encoding=utf-8 -jar --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED -Ddruid.mysql.usePingMethod=false -Xms10240M -Xmx10240M system-0.0.1.jar >> main.log 2>&1 &
- restart
#!/bin/bash
bash stop.sh
bash start.sh
网友评论