编辑/etc/rc.d/下的rc.local文件
1.如果还没有给与rc.local文件可执行权限,则先执行命令赋予rc.local可执行权限
chmod +x /etc/rc.d/rc.local
2.然后vi rc.local文件,以在/mnt/why文件夹下执行脚本为例,加上开机执行的动作:
touch /var/lock/subsys/local
cd /mnt/why
./monitor.sh >> logfile.log 2>&1
systemctl restart IPLocationService
3.如果未执行成功,查看logfile.log日志,如果未找到脚本中的某个命令,但在Xshell又可以执行的话,则在脚本中的命令前加上
source /etc/profile