Jar text (server run)

Source: Internet
Author: User
Tags shebang

Just look at the jar and make a short note here because you need to run a jar program that collects data on the server at a timed time:

1.eclipse-export to generate a runnable jar to the specified directory. The third-party jar package that you rely on is packaged into the specified directory at the same time.

Note: Runnable jar– will automatically pack all your dependent jar packages into the specified directory that you want to export while hitting the jar package. (Project Jar MANIFEST. The path of the third-party dependency package is specified in the MF file, i.e. classpath)

2.window Test:
CMD switch to your exported jar path, command Java-jar jar name. jar

Linux has not yet been deployed, not much to say. Take it yourself.

Script one: The starttest.sh content is as follows:#!/bin/shJava-jar Test.jar &#注意: Must have & let its background execute, otherwise there is no PID generationEcho$! >/var/run/test.pid# Start the corresponding PID in the jar package to write to the file, to provide PID when stoppingStoptest.sh content is as follows:#!/bin/shpid=$ (cat/var/run/test.pid) Kill-9 $PIDScript two:#!/bin/sh#启动方法Start() {Java-xms128m-xmx2048m-jar Test1.jar5> Log.log & Java-xms128m-xmx2048m-jar Test2.jar5> Log.log & Tail- FResult.log}#停止方法Stop() {Ps-ef|grep Test|awk' {print $} '| while ReadPid DoKill-9 $pid         Done} Case "$" inchStart) Start; stop) stop;; restart) stop start;; *)printf ' Usage:%s {start|stop|restart}\n ' "$prog"  Exit 1;;Esac

Jar text (server run)

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.