前提是保证自定义脚本文件本身是没有问题的。
直接文件里添加执行命令,文件路径必须是完整绝对路径
1 #!/bin/bash
2 # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
3 #
4 # It is highly advisable to create own systemd services or udev rules
5 # to run scripts during boot instead of using this file.
6 #
7 # In contrast to previous versions due to parallel execution during boot
8 # this script will NOT be run after all other services.
9 #
10 # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
11 # that this script will be executed during boot.
12 bash /home/tomcat/apache-tomcat-9.0.0.M15/bin/startup.sh
13 touch /var/lock/subsys/local
然后,给文件授权
chmod +777 /etc/rc.d/rc.local
重启机器,查看进程启动成功。文件执行成功。