2010年2月5日 星期五

[Ubuntu] 中使用 service

瀏覽數
#!/bin/sh # Set up a default search path. PATH="/sbin:/usr/sbin:/bin:/ usr/bin:/usr/X11R6/bin" export PATH VERSION="`basename $0` ver. 0.91" USAGE="Usage: `basename $0` < option > | --status-all | \ ]" SERVICE= SERVICEDIR="/etc/init.d" OPTIONS= if ; then    echo $"${USAGE}" >&2    exit 1 fi cd / while ; do   case "${1}" in     --help | -h | --h* )        echo $"${USAGE}" >&2        exit 0        ;;     --version | -V )        echo $"${VERSION}" >&2        exit 0        ;;     *)        if ; then           cd ${SERVICEDIR}           for SERVICE in * ; do             case "${SERVICE}" in               functions | halt | killall | single| linuxconf| kudzu | \                   *rpmorig | *rpmnew | *rpmsave | *~ | *.orig)                   ;;               *)                 if ; then                   env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" status                 fi                 ;;             esac           done           exit 0        elif ; then           SERVICE="${1}"           if ; then             env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" stop             env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" start             exit $?           fi        elif ; then          SERVICE="${1}"        else          OPTIONS="${OPTIONS} ${1}"        fi        shift        ;;    esac done if ; then    env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" ${OPTIONS} else    echo $"${SERVICE}: unrecognized service" >&2    exit 1 fi 1.將上面的紅色程式碼複 製 起來 2.儲存存到 /sbin/service 3.chown root:root /sbin/service 4.chmod 755 /sbin/service 您可以使用 service mysql restart 指令取代 /etc/init.d/mysql restart

沒有留言: