BLOGTIMES
2014/06/04

/etc/init.d/hoge start と service hoge start は何が違う?

  systemmanagemant  cli 
このエントリーをはてなブックマークに追加


Linux  /etc/init.d/hoge *1 service hoge 使
 /etc/init.d/hoge start  service hoge start 

2
2調

 service /sbin 

# which service /sbin/service

調

 man 

 man 
 /etc/init.d/hoge  init.d 
 / 
# man service service(8) service(8) NAME service - run a System V init script SYNOPSIS service SCRIPT COMMAND [OPTIONS] service --status-all service --help | -h | --version DESCRIPTION service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /. The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT. The supported values of COM- MAND depend on the invoked script, service passes COMMAND and OPTIONS it to the init script unmodified. All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. service --status-all runs all init scripts, in alphabetical order, with the status command. FILES /etc/init.d The directory containing System V init scripts. ENVIRONMENT LANG, TERM The only environment variables passed to the init scripts. SEE ALSO chkconfig(8), ntsysv(8) Jan 2006 service(8)

ちなみに中身はバイナリではなく普通のシェルスクリプトでした。

# cat /sbin/service #!/bin/sh . /etc/init.d/functions VERSION="`basename $0` ver. 0.91" USAGE="Usage: `basename $0` < option > | --status-all | \ [ service_name [ command | --full-restart ] ]" SERVICE= SERVICEDIR="/etc/init.d" OPTIONS= if [ $# -eq 0 ]; then echo "${USAGE}" >&2 exit 1 fi cd / while [ $# -gt 0 ]; do case "${1}" in --help | -h | --h* ) echo "${USAGE}" >&2 exit 0 ;; --version | -V ) echo "${VERSION}" >&2 exit 0 ;; *) if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then cd ${SERVICEDIR} for SERVICE in * ; do case "${SERVICE}" in functions | halt | killall | single| linuxconf| kudzu) ;; *) if ! is_ignored_file "${SERVICE}" \ && [ -x "${SERVICEDIR}/${SERVICE}" ]; then env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" status fi ;; esac done exit 0 elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then SERVICE="${1}" if [ -x "${SERVICEDIR}/${SERVICE}" ]; 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 [ -z "${SERVICE}" ]; then SERVICE="${1}" else OPTIONS="${OPTIONS} ${1}" fi shift ;; esac done if [ -x "${SERVICEDIR}/${SERVICE}" ]; then env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS} else echo $"${SERVICE}: unrecognized service" >&2 exit 1 fi

 CentOS 

CentOS 6.x  service  man 


service - way - Powered by HEARTBEATS

manPATH, LANG調"/sbin/service"2

PATH2() "/etc/init.d/functions"
38, 47, 48, 62(1)PATH, TERM"env -i"PATH, TERM


*1: /etc/init.d/hoge 便

トラックバックについて
Trackback URL:
お気軽にどうぞ。トラックバック前にポリシーをお読みください。[policy]
このエントリへのTrackbackにはこのURLが必要です→https://blog.cles.jp/item/6767
Trackbacks
このエントリにトラックバックはありません
Comments
愛のあるツッコミをお気軽にどうぞ。[policy]
古いエントリについてはコメント制御しているため、即時に反映されないことがあります。
コメントはありません
Comments Form

コメントは承認後の表示となります。
OpenIDでログインすると、即時に公開されます。

OpenID を使ってログインすることができます。

Identity URL: Yahoo! JAPAN IDでログイン