欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

Ubuntu设置开机启动

发布时间:2025/3/15 39 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Ubuntu设置开机启动 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

1. 创建执行脚本

touch test.sh

2. 编写test.sh脚本

cd /opt/server ./test.sh exit 0

3. 移动test.sh文件到/etc/init.d目录下(开启启动目录)

# 移动文件 sudo mv test.sh /etc/init.d/ # 给文件增加权限 chmod +755 test.sh # 设置开机自动启动 sudo update-rc.d test.sh defaults

4. 去除开机启动脚本

update-rc.d start.sh -f test.sh remove

5. 查看系统启动项

systemctl list-unit-files

6. 查看服务状态

systemctl status test.service

7. 禁用开机启动示例

sudo systemctl disable mongodb.service sudo systemctl disable nginx.service sudo systemctl disable redis-server.service

8. 停止已经开启的服务示例

sudo systemctl stop mongodb.service sudo systemctl stop nginx.service sudo systemctl stop redis-server.service

参考:

  • Ubuntu/CentOS查看系统启动项_公众号shadow sock7-CSDN博客_ubuntu查看开机启动项
  • update-rc.d的具体用法_maxuearn的博客-CSDN博客
  • https://www.jb51.net/article/175654.htm

总结

以上是生活随笔为你收集整理的Ubuntu设置开机启动的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。