自宅サーバの整理箱

自宅サーバを構築しwordpress,fedora,CentOSの作業メモ

*

Linuxの自動起動(rc.d)スクリプト デーモン登録

   

Linux
自動起動スクリプトをつくってデーモン登録。
/etc/rc.d/init.d/に任意の名前で作成します。

#!/bin/bash
#
#
# chkconfig: 345 99 01
# processname: user_deamon_name
# description: user_description

PROG=
PROGNAME=
LOCKFILE=/var/lock/subsys/$PROGNAME

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
exit 0
fi

start() {
echo -n "Starting $PROGNAME services: "
実行コマンド
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $LOCKFILE
return $RETVAL
}

stop() {
echo -n "Stopping $PROGNAME services: "
killproc $PROGNAME
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $LOCKFILE
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $PROGNAME
;;
restart|reload)
stop
start
;;
*)
echo "Usage: $PROGNAME {start|stop|status|restart}"
exit 1

esac

exit $RETVAL

 - 自宅サーバ

 Total 22 views