1、增加服务文件
vi /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
2、增加rc.local文件
vi /etc/rc.local
#!/bin/sh -e
exit 0
添加权限:
chmod +x /etc/rc.local
设置到系统启动:
systemctl enable rc-local
启动脚本:
systemctl start rc-local.service
检查服务状态:
systemctl status rc-local.service
你已经增加了系统启动脚本,可以在这个脚本里面增加你想启动的程序,例如
cd /home/gst/tomcat/bin
./strat.sh\