美文网首页
Ubuntu 添加自启动服务

Ubuntu 添加自启动服务

作者: 庐州散人2017 | 来源:发表于2018-11-20 11:03 被阅读0次

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

相关文章

网友评论

      本文标题:Ubuntu 添加自启动服务

      本文链接:https://www.haomeiwen.com/subject/fpytqqtx.html