【发布时间】:2012-08-01 11:50:22
【问题描述】:
我在 linux(Redhat Server Edition 5.1) 上编写了一项服务。它由 shell 脚本启动, 如果我启动我的应用程序我手动启动我的服务,现在我想在启动时启动我的服务,这意味着我通过我的守护进程将我的服务放在 init.d 文件夹中,而不是在启动时调用,任何人都知道如何启动linux 启动时的守护进程?
这是我的示例,但不起作用
#!/bin/sh
#
# myservice This shell script takes care of starting and stopping
# the <myservice>
#
# Source function library
. /etc/rc.d/init.d/functions
# Do preliminary checks here, if any
#### START of preliminary checks #########
##### END of preliminary checks #######
# Handle manual control parameters like start, stop, status, restart, etc.
case "$1" in
start)
# Start daemons.
echo -n $"Starting <myservice> daemon: "
echo
daemon <myservice>
echo
;;
stop)
# Stop daemons.
echo -n $"Shutting down <myservice>: "
killproc <myservice>
echo
# Do clean-up works here like removing pid files from /var/run, etc.
;;
status)
status <myservice>
;;
restart)
$0 stop
$0 start
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
【问题讨论】:
标签: linux linux-kernel daemon redhat