Shell script for Linux to start the jar package

Source: Internet
Author: User

This article mainly introduces the shell script for Linux to start the jar package. It is very good and has reference value. If you need it, refer

 

Background:

The device of the project needs to run the jar package program to connect to the server through socket and send data. Each time a process is started, you need to enter the command to start the jar package on the Linux terminal, which is cumbersome, then try to write the command to start the jar package to the shell script file to start the jar package program.

The command in the compiled socdev. sh script file is as follows:

 
123456789101112131415161718192021222324252627282930 # Directory of the startup commandHOME='/home/pi/Desktop/java'# Obtain the mac address (unique)
mac=`ifconfig | grep eth0 | awk '{print $5}'`
start(){  # Enter the command directory  cd $HOME  nohup sudo java -jar ufoCatcher-catcher-1.0-SNAPSHOT.jar $mac wss://ip:port/catcher PULL_DOWN &}stop(){  # Kill all java programs  ps -ef | grep java | grep -v grep |awk '{print $2}' | xargs sudo kill -9}case $1 in  start)   start  ;;  stop)   stop  ;;  restart)   $0 stop   sleep 2   $0 start  ;;  *)   echo "Usage: {start|stop|restart}"  ;;esacexit 0

Start the jar package program:./socdev. sh start

Terminate the jar package program:./socdev. sh stop

Summary

The above is the shell script for Linux to start the jar package. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. I would like to thank you for your support for the script home website!

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.