简单的一个shell脚本
[root@test173 ~]#cat /root/bb.sh
#!/bin/bash
touch /mnt/1.txt
echo ‘aaaa’ > /mnt/2.txt
网上都说修改这个 /etc/rc.local就行,实际上修改 /etc/rc.local等于修改/etc/rc.d/rc.local这个文件
[root@test173 ~]# ls -ld /etc/rc.local
lrwxrwxrwx. 1 root root 13 8月 16 15:35 /etc/rc.local -> rc.d/rc.local
查看这个文件发现没有执行权限需要添加一下执行权限
[root@test173 ~]#ls -ld /etc/rc.d/rc.local
-rw-r–r--1 root root 466 10月 31 10:44 /etc/rc.d/rc.local
[root@test173 ~]# chmod +x /etc/rc.d/rc.local
然后重启机器
发现/mnt就有1.txt和2.txt文件,说明开机时候执行了脚本了