1.在目录/etc下创建文件rc.local文件
2.该文件内容为:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
bash /bin/test.sh &
exit 0
rc.local中会执行/bin目录下的test脚本。
3.chmod +x rc.local设置权限。
4.test.sh脚本内容:
#!/bin/bash
sleep 10s
reboot
5.chmod +x test.sh设置权限
6.测试