https://www.jianshu.com/p/1e1080a39dc5
#!/bin/bash
if [ -s java.pid ]
then
echo "重复启动,退出"
exit 0
fi
jar_file=`ls *.jar | head -n 1`
echo $jar_file
java -Djava.security.egd=file:/dev/./urandom -jar $jar_file > test.log 2>&1 &
echo $! > java.pid
#!/bin/bash
if [ -s java.pid ]
then
echo "重复启动,退出"
exit 0
fi
jar_file=`ls *.jar | head -n 1`
echo $jar_file
java -Djava.security.egd=file:/dev/./urandom -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 -jar $jar_file > test.log 2>&1 &
echo $! > java.pid
通过-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
来指定debug端口为8000
#!/bin/bash
if [ -s java.pid ]
then
echo "重复启动,退出"
exit 0
fi
jar_file=`ls *.jar | head -n 1`
echo $jar_file
java -Djava.security.egd=file:/dev/./urandom -jar $jar_file --spring.profiles.active=test > test.log 2>&1 &
echo $! > java.pid
如果需要指定某个配置文件,可以通过--spring.profiles.active=test
来指定。
#!/bin/bash
if [ -s java.pid ]
then
kill -9 `cat java.pid` && : > java.pid
fi
将run.sh
和stop.sh
和xxxx.jar
包放同一目录