一的那个脚本自己写的 比较low 找了个好的脚本并且做成服务
#!/bin/sh
source /etc/rc.d/init.d/functions
export JAVA_HOME=/usr/local/jdk1.8.0_161/
export LOG_DIR=/data/himalayasEtl/log
ETL_HOME=/usr/local/himalayasetl/
PIDFILE=$ETL_HOME/myid/etl.pid
export CLASSPATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$ETL_HOME/lib" 自己项目的lib jar依赖位置
JAVA_OPTIONS="-Dfile.encoding=utf8 -Djava.ext.dirs=$CLASSPATH"
# See how we were called.
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
nohup $JAVA_HOME/bin/java $JAVA_OPTIONS -cp $ETL_HOME/config:$ETL_HOME/himalayas-stream-source-1.0-SNAPSHOT.jar com.yjp.himalaya.stream.kafkatohbase.YjpETLClient > "$LOG_DIR/etlDeamon.log" 2>&1 &
echo $! > $PIDFILE
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
kill -9 $PID
rm $PIDFILE
fi
;;
status)
PID=$(cat $PIDFILE)
if [ ! -x /proc/${PID} ]
then
echo 'himalayas etl is not running'
else
echo "himalayas etl is running ($PID)"
fi
;;
restart)
stop
start
;;
*)
echo "Usage: cassandra {start|stop|hardstop|status|restart}"
exit 1
;;
esac
服务脚本:和第一篇文章差不多
[Unit]
Description=service for description
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/himalayasetl/script/himalayasETL start
ExecStop=/usr/local/himalayasetl/script/himalayasETL stop
ExecReload=/usr/local/himalayasetl/script/himalayasETL restart
PrivateTmp=true
[Install]
WantedBy=multi-user.target
全是copy的,努力吧 皮卡丘