Last active
November 29, 2017 04:40
-
-
Save usmansaleem/14de7aed8fc70344f49b0ce70e082d91 to your computer and use it in GitHub Desktop.
A simple (Linux) sh script to launch a jar in background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# sh run-blog.sh start|stop | |
PIDFILE="/root/blog.pid" | |
JAVA_HOME="/opt/jdk" | |
JARFILE="/root/uzi-vertx-shadow.jar" | |
case $1 in | |
start) | |
if [ ! -f $PIDFILE ]; then | |
nohup $JAVA_HOME/bin/java -jar $JARFILE 2>> /dev/null >> /dev/null & | |
echo $! > $PIDFILE | |
echo "blog started!" | |
else | |
echo "blog is already running ..." | |
fi | |
;; | |
stop) | |
if [ -f $PIDFILE ]; then | |
PID=$(cat $PIDFILE); | |
echo "Stopping blog..." | |
kill $PID; | |
echo "blog stopped!" | |
rm $PIDFILE | |
else | |
echo "blog is not running ..." | |
fi | |
;; | |
*) | |
echo "Usage: run-blog.sh start stop" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment