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)