Linux配置开机自启动执行脚本

方法一:修改/etc/rc.local

/etc/rc.local ,该文件为链接文件

# ll /etc/rc.local 
lrwxrwxrwx. 1 root root 13 Feb  5 10:03 /etc/rc.local -> rc.d/rc.local

修改/etc/rc.local文件

# tail -n 1 /etc/rc.local 
/bin/bash /server/scripts/qidong.sh >/dev/null 2>/dev/null

方法二:chkconfig管理

# vim /etc/init.d/test 
#!/bin/bash
# chkconfig: 3 88 88
/bin/bash /server/scripts/qidong.sh >/dev/null 2>/dev/null# chmod +x /etc/init.d/test

添加到chkconfig,开机自启动

# chkconfig --add test
# chkconfig --list test
test               0:off    1:off    2:off    3:on    4:off    5:off    6:off

关闭开机启动

# chkconfig test off
# chkconfig --list test
test               0:off    1:off    2:off    3:off    4:off    5:off    6:off

从chkconfig管理中删除test

# chkconfig --list test
test               0:off    1:off    2:off    3:off    4:off    5:off    6:off

# chkconfig --del test

# chkconfig --list test
service test supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add test')

 

posted @ 2021-02-26 11:01  白虎  阅读(128)  评论(0编辑  收藏  举报
非常感谢dudu,感谢博客园提供的各种服务。
联系白虎(David.Du)