标签:jre_home boot hup val else roo ror jdk1.7 停止
springboot学习比较总结:https://pan.baidu.com/s/1dYwvpkJava系统部署脚本:
当想把程序放到后台运行: nohup ./your_command &
部署Java:
1. 在eclipse上使用maven打包项目:clean package
2. 找到工作目录:E:\work\mywork\ad_logsIndex\target
3. 将两个文件复制到Linux的一个目录下(我用filezilla工具来复制文件),并且写启动脚本
#!/bin/bash prog=logsindex JAVA_HOME=/usr/java/jdk1.8.0_144 prog_dir=/opt/webapps/logsindex start() { echo -n $"Starting $prog: " cd $prog_dir screen -dmS $prog $JAVA_HOME/bin/java -jar -Xms2048m -Xmx4096m $prog_dir/ad_logsIndex-0.0.1-SNAPSHOT.jar com.voole.ad.main.StartUp -Djava.ext.dirs=$prog_dir/lib retval=$? echo [ $retval -eq 0 ] return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog retval=$? echo [ $retval -eq 0 ] return $retval } case "$1" in start) $1 ;; stop) $1 ;; *) echo $"Usage: $0 {start|stop}" exit 2 esac
4. 修改权限:
# chmod a+x ad_logsIndex-0.0.1-SNAPSHOT.jar
# chmod a+x start.sh
5. 启动
[root@localhost logsindex]# ./start.sh start
Starting logsindex:
6. 停止服务
方法一:
[root@localhost logsindex]# ./start.sh stop
注意:logsindex名称是在脚本中(prog=logsindex)配置的
方法二:
# ps -ef | grep logsindex
然后通过kill命令+进程号切断进程。
方法三:
# screen -r logsindex
Ctrl+A+D:退出但不停止进程
Ctrl+C :退出进程
另外见过的脚本:
#!/bin/sh ## chang here SERVICE_DIR=/roncoo/spring-boot-demo SERVICE_NAME=spring-boot-demo-31-1-0.0.1-SNAPSHOT SPRING_PROFILES_ACTIVE=dev ## java env export JAVA_HOME=/opt/jdk1.7.0_79 export JRE_HOME=${JAVA_HOME}/jre case "$1" in start) procedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'` if [ "${procedure}" = "" ]; then echo "start ..." if [ "$2" != "" ]; then SPRING_PROFILES_ACTIVE=$2 fi echo "spring.profiles.active=${SPRING_PROFILES_ACTIVE}" exec nohup ${JRE_HOME}/bin/java -Xms128m -Xmx512m -jar ${SERVICE_DIR}/${SERVICE_NAME}\.jar --spring.profiles.active=${SPRING_PROFILES_ACTIVE} >/dev/null 2>&1 & echo "start success" else echo "${SERVICE_NAME} is start" fi ;; stop) procedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'` if [ "${procedure}" = "" ]; then echo "${SERVICE_NAME} is stop" else kill -9 ${procedure} sleep 1 argprocedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'` if [ "${argprocedure}" = "" ]; then echo "${SERVICE_NAME} stop success" else kill -9 ${argprocedure} echo "${SERVICE_NAME} stop error" fi fi ;; restart) $0 stop sleep 1 $0 start $2 ;; *) echo "usage: $0 [start|stop|restart] [dev|test|prod]" ;; esac
标签:jre_home boot hup val else roo ror jdk1.7 停止
原文地址:http://blog.51cto.com/qinbin/2067361