一、修改开机启动文件:/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脚本。
网友评论