1、脚本存放在/etc/init.d位置下,文件名如 hello,记得加上可执行权限。
sudo vi /etc/init.d/hello
sudo chmod +x /etc/init.d/hello
2、在脚本内编辑一下内容
### BEGIN INIT INFO
# Provides: lsb-ourdb
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop OurDB
# Description: OurDB is a very fast and reliable database
# engine used for illustrating init scripts
### END INIT INFO
3、命令行输入
sudo systemctl enable hello