Windows bat script on a button, packing, transport to the linux server, running

Pscp installation and plink

https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

bat script

@echo off
Chinese rem print is not garbled, the default is gbk, instead utf8
chcp 65001
rem copy the file name
set name=zhong-eureka
rem copy the full path of the file
set folder=E:\git\zhong\%name%\target\%name%.jar
rem server IP
set ip=192.168.1.107
rem server password
password SET = 123456 
echo  " package .. "
e:
E cd: \ git \ zhong \ % name% 
Call mvn Clean install -Dmaven.test.skip = to true 
echo  " transfer to the linux server home directory ... " 
the PSCP -pw Folder%%%% password root @% ip% : / Home /
 echo  " start, sh script on a remote call linux server ... " 
Plink the -batch -pw root @% password%%% ip / Home /% name%. SH
@cmd.exe
exist

 

The script linux sh

#!/bin/sh
# This file must be placed in the directory of a jar, as is the relative path to run. Hold jar package directory, you can write directly in the path of absolute parameters jar_name
#start set three parameters 
#surroundings
profile=
#jar path and name
jar_name=/home/zhong-eureka.jar
# Remote breakpoint port
remote_address=
#end set three parameters
echo  " Run jar_name $ " 
# query process, and to kill the current JAR / the Java process
PID = ` PS -ef | grep $ jar_name the | grep -v grep | awk  ' {2} Print $ ' `
 echo  " Process for the PID $ " 
the kill - . 9 $ PID
 echo  " $ PID process terminates successfully " 
SLEEP  2 
Source / etc / profile
# Determine whether the jar package file exists, if there starts jar package, and always view the boot log
IF the Test - E $ jar_name
 the then 
echo  " $ jar_name existence, started this program ... "
    # Determine whether there is a breakpoint remote port
    if test -z "$remote_address"
    then
      # Start jar package
      Java the nohup -Xms64m -Xmx128m jar_name the -jar $> / dev / null  2 > & . 1 &
       echo  " remote port is empty break " 
    the else  
      # Start jar package
      the Java nohup -Xms64m -Xmx128m -jar $ jar_name> / dev / null  2 > & 1 &
       echo  " remote port to break remote_address $ " 
    fi 
echo  " $ jar_name started successfully ... " 
pid = ` PS -ef | grep $ jar_name | grep -v grep | awk  ' {Print $ 2} ' `
 echo  " new process for the pid $ " 
the else 
echo  " $ jar_name file does not exist, check. " 
fi

 

Guess you like

Origin www.cnblogs.com/suruozhong/p/12100535.html