The Linux environment directly runs the jar package to start the project

#!/bin/sh
SERVICE=$1
LOG_FILE=./logs/${SERVICE}`date +%Y%m%d%H`.log
touch ${LOG_FILE}
nohup java -jar ${SERVICE}.jar > ${LOG_FILE} 2>&1 &
tail -f ${LOG_FILE}

 

  Save the above as app_start.sh

  

 Example:

      If there is a runnable aa.jar package in a directory, the running command is

      sh app_start.sh aa

     

 operation result:

    When running, the log will be output directly, and the running log file will be generated according to the current log in the logs directory under the current directory.

 

 

In addition, pay attention to the command copied from the windows system, the execution may report $'\r': command not found

 

   ../runcmake: line 2: $'\r': command not found

 ../runcmake: line 3: syntax error near unexpected symbol `$'{\r''

 

    solution:

   sudo apt-get install dos2unix

   dos2unix **.sh

 

 

 

    centos solution:

   yum install dos2unix

   dos2unix **.sh

 

 

 

     

   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326396273&siteId=291194637