1. 在/etc/init.d 里添加文件, 如 test, 内容如下
#!/bin/bash
### BEGIN INIT INFO
# Provides: test
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: slapd cups
# Should-Stop: slapd cups
# Short-Description: test
# Description: test
### END INIT INFO
case $1 in
start):
xxxxxx do something
;;
stop):
;;
esac
exit 0
2.设置文件可执行 chmod a+x test
3. 设置服务
systemctl daemon-reload
systemctl enable test
网友评论