init.d的启动脚本是比较古老的系统才使用的,那么如何制作init.d的启动脚本呢?

示例:创建 /etc/init.d/myscript,内容如下:

#!/bin/bash
# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
# code to start app comes here
# example: daemon program_name &
}

stop() {
# code to stop app comes here
# example: killproc program_name
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
# code to check status of app comes here
# example: status program_name
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac

exit 0

参考资料

How can I make a script in /etc/init.d start at boot?


如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《如何制作init.d的启动脚本》相关的博文:


留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌