ubuntu22添加系统启动脚本 Published on Nov 12, 2023 in 随笔 with 0 comment 前言 Ubuntu 18 不再使用initd管理系统,而是使用systemd;我们使用 update-rc.d,可以添加和删除服务,并将它们添加到Ubuntu / Debian启动脚本中,实现开启自启动效果。 实现过程 新建脚本new_service.sh #!/bin/bash # command content exit 0 设置权限 sudo chmod +x new_service.sh 将文件移动到启动目录下 sudo mv new_service.sh /etc/init.d/ 添加启动脚本 sudo update-rc.d new_service.sh defaults 90 查看服务列表 sudo service --status-all 服务相关操作 sudo service xxx status sudo service xxx start sudo service xxx stop sudo service xxx restart 移除开机脚本 sudo update-rc.d -f new_service.sh remove 本文由 admin 创作,采用 知识共享署名4.0 国际许可协议进行许可。本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。