CentOS7添加需要開機啟動的腳本
1、修改開機腳本添加文件的權限
[[email protected] ~]# cat /etc/rc.d/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run ‘chmod +x /etc/rc.d/rc.local‘ to ensure # that this script will be executed during boot. touch /var/lock/subsys/local 說明:如上可知,在CentOS7中,/etc/rc.d/rc.local文件的權限被降低了,開機的時候執行在自己的腳 本是不能啟動的,所有需要添加可執行的權限 [[email protected]
2、添加一個清空iptables策略的開機腳本
[[email protected] ~]# mkdir -p /shells/ [[email protected] ~]# vim /shells/clean_iptables.sh #!/bin/bash /usr/sbin/iptables -F /usr/sbin/iptables -X /usr/sbin/iptables -Z /usr/sbin/setenforce 0 [[email protected]