Jar background Run script window-bat/unix-sh for Springboot

Source: Internet
Author: User
Tags app service

Springboot project, packaged directly into jars

With Tomcat, you can run directly from Java commands without web App service.

For Maven, for example, configure the packaged output type in Pom.xml:

<packaging>jar</packaging>

Configuration build:

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Once packaged as a jar, it can be started or stopped directly through batch processing.

Window-bat

Start

@echo off
: WMIC process where "commandline like '%%-jar reportcheck%% '" Call terminate
Set path=C:\Program files\java\jre1.8.0_91\bin
Reportcheck-0.0.1-snapshot.jar
Pause

Stop

@echo off
reportcheck' "Call terminate
Pause

Unix-sh

Start

#!/bin/bash
If PS aux | Grep-v ' grep ' | grep ' java ' | grep ' Reportcheck.jar '
Then
pid=$ (ps aux | grep-v ' grep ' |grep ' java ' |grep ' Reportcheck.jar ' | awk ' {print $} ');
echo pid;
Kill-9 ${pid};
echo Old Reportcheck exit ...;
Fi
Nohup Java-jar Reportcheck.jar &> out &
Echo Reportcheck running ...

Stop

#!/bin/bash
If PS aux | Grep-v ' grep ' | grep ' java ' | grep ' Reportcheck.jar '
Then
pid=$ (ps aux | grep-v ' grep ' |grep ' java ' |grep ' Reportcheck.jar ' | awk ' {print $} ');
Echo PID
Kill-9 ${pid};
Fi

Jar background Run script window-bat/unix-sh for Springboot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.