我在linux上编写了一个服务(Redhat Server Edition 5.1)。这是通过shell scritpt启动的, 在我启动我的应用程序的情况下,我手动启动我的服务,现在我想在启动时启动我的服务,通过手段我把我的服务放在init.d文件夹中,我的守护进程不会在启动时调用时间,任何有想法如何启动一个守护进程在Linux上启动时?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
什么事情发生增加了两个注释行到该脚本我不能得到你, – 2012-08-01 12:06:23
这些行会告诉chkconfig的你的脚本应该运行的运行级别以及启动和停止的优先级。看到这个:http://linux.die.net/man/8/chkconfig – yanjost 2012-12-04 15:39:33
如果服务已经列出,你可能需要运行chkconfig --del my_service,然后再执行--add – 2014-04-01 20:17:14