run.sh
#!/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
Run.sh with debug
#!/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
Use -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
to specify the debug port as 8000
Specify run.sh of the configuration file
#!/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
If you need to specify a configuration file, you can --spring.profiles.active=test
specify it.
stop.sh
#!/bin/bash
if [ -s java.pid ]
then
kill -9 `cat java.pid` && : > java.pid
fi
How to use
The run.sh
and stop.sh
and xxxx.jar
bag put in the same directory