启动时要启动的脚本qidong.sh[root@c69-01scripts]#vim/server/scripts/qidong.sh[root@c69-01scripts]#cat/server/scripts/qidong.sh#!/bin/bash/bin/echo$(/bin/date+%F_%T)>>/tmp/qidong.log方法一:修改/etc/rc.local/etc/rc.local,这是一个链接文件[root@c69-01~]#ll/etc/rc.locallrwxrwxrwx.1rootroot13Feb510:03/etc/rc.local->rc.d/rc.local修改/etc/rc.local文件[root@c69-01scripts]#tail-n1/etc/rc.local/bin/bash/server/scripts/qidong.sh>/dev/null2>/dev/null重启系统查看结果[root@c69-01~]#cat/tmp/qidong.log2018-02-19_23:30:56脚本已自动启动。方法二:chkconfig管理删除方法一的配置[root@c69-01~]#vim/etc/init.d/test#!/bin/bash#chkconfig:38888/bin/bash/server/scripts/qidong.sh>/dev/null2>/dev/null[root@c69-01~]#chmod+x/etc/init.d/test加入chkconfig,开机自动启动[root@c69-01~]#chkconfig--addtest[root@c69-01~]#chkconfig--listtesttest0:off1:off2:off3:on4:off5:off6:off重启系统查看结果[root@c69-01~]#cat/tmp/qidong.log2018-02-19_23:30:562018-02-19_23:59:10运行成功关闭并启动[root@c69-01~]#chkconfigtestoff[root@c69-01~]#chkconfig--listtesttest0:off1:off2:off3:off4:off5:off6:off从chkconfig管理中删除测试[root@c69-01~]#chkconfig--listtesttest0:off1:off2:off3:off4:off5:off6:off[root@c69-01~]#chkconfig--deltest[root@c69-01~]#chkconfig--listtestservicetestsupportschkconfig,butisnotreferencedinanyrunlevel(run'chkconfig--addtest')以上两种开机自启动脚本的方法仅供参考,读者大家可以根据自己的情况进行配置!注:我使用的系统是CentOSrelease6.9(Final)
