将服务变为系统服务
Posted wt11
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将服务变为系统服务相关的知识,希望对你有一定的参考价值。
[[email protected] init.d]# cat elasticsearch #!/bin/sh # elasticsearch Startup script for the elasticsearch # # chkconfig: 2345 80 05 # description: The elasticsearch will store data # processname: elasticsearch ### BEGIN INIT INFO # Provides: elasticsearch # Required-Start: $all # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start elasticsearch at boot time ### END INIT INFO DESC="ES" SEVICE_NAME=elasticsearch PIDFILE=/var/run/$NAME.pid RUN_AS=es COMMAND="/home/es/es_for_cmdb/elasticsearch/bin/elasticsearch" es_start() { if [ -e $PIDFILE ] then echo "$SEVICE_NAME is running..." else start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --exec $COMMAND echo "Starting $DESC: $SEVICE_NAME" fi } es_stop() { start-stop-daemon --stop --quiet --pidfile $PIDFILE if [ -e $PIDFILE ] then rm $PIDFILE fi } es_status() { if [ -e $PIDFILE ] then echo "$SEVICE_NAME is running..." else echo "$SEVICE_NAME not run!" fi } case $1 in start) es_start echo "ok!" ;; stop) echo "Stopping $DESC: $SEVICE_NAME" es_stop echo "ok!" ;; restart) echo "Restarting $DESC: $SEVICE_NAME" es_stop sleep 1 es_start echo "ok!" ;; status) es_status ;; *) echo "usage: /etc/init.d/$SEVICE_NAME {start|stop|status|restart}" exit 1 ;; esac exit 0
以上是关于将服务变为系统服务的主要内容,如果未能解决你的问题,请参考以下文章