发布网友
共6个回答
热心网友
你把我下面给你的脚本复制下,然后定名为service,放到/sbin/下
#!/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
其实service就是一个脚本,这是我linux上的。你还可以把service名改成abc等其他的名字,服务就可以 abc 服务 start|stop|status 了,嘿嘿...
当然也可能直接用不了,那你就需要加上/sbin/service了,或者你在/etc/profile中加个变量
export PATH=/sbin/:/usr/sbin/ 就可以了 记得让变量生效啊 source /etc/profile
如果有错,自行更改,我英文不好...
热心网友
有的发行版本来就不会装service的,比如arch,arch是用systemd来管理服务、进程的。你看看自己的发行版到底是用的什么
热心网友
很奇怪,service在装OS时就应当装了。这是来自RedHat:
$which service
/sbin/service
$rpm -qf /sbin/service
initscripts-8.45.30-2.e15
热心网友
gentoo中也没service,有些操作可以用:
/etc/init.d/nginx restart
来代替。追问我现在只想用service命令
热心网友
没有,不i过可以6用其他命令实现,自己d写个vpause也f不q难吧c籁mnイliゥ农fiゥ农ej浴病tㄛЖ
热心网友
你怎么知道没有service
用 which service 查找一下追问我用service 然后提示not fand