CentOS系统和Redhat系统如下:
1.修改/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
source /root/Desktop/start.sh
“sourece /root/Desktop/start.sh”为要添加开机自启动的脚本,并且要给“/root/Desktop/start.sh”赋予执行权限(chmod +x /root/Desktop/start.sh)
2.chmod 777 rc.local
3.重启系统后就会开始执行预设置执行的脚本。(此种自启动方式不会在GUI界面显示执行的具体进程)**