美文网首页
Linux—添加开机启动(服务/脚本)

Linux—添加开机启动(服务/脚本)

作者: 可能性之兽 | 来源:发表于2022-10-18 09:49 被阅读0次

一、修改开机启动文件:/etc/rc.local(或者/etc/rc.d/rc.local)

# 1.编辑rc.local文件
[root@localhost ~]# vi /etc/rc.local

# 2.修改rc.local文件,在 exit 0 前面加入以下命令。保存并退出。
/etc/init.d/mysqld start                                         # mysql开机启动
/etc/init.d/nginx start                                          # nginx开机启动
supervisord -c /etc/supervisor/supervisord.conf                  # supervisord开机启动
/bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null

# 3.最后修改rc.local文件的执行权限
[root@localhost ~]# chmod +x  /etc/rc.local
[root@localhost ~]# chmod 755 /etc/rc.local

二、自己写一个shell脚本

将写好的脚本(.sh文件)放到目录 /etc/profile.d/ 下,系统启动后就会自动执行该目录下的所有shell脚本。

Linux—添加开机启动(服务/脚本) - 刘love田 - 博客园 (cnblogs.com)

相关文章

网友评论

      本文标题:Linux—添加开机启动(服务/脚本)

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