Debian 9设置开机启动

Outshine 2018-06-24 | 阅读 8232

新增文件:

nano /etc/systemd/system/rc-local.service

编辑内容:

或者
[Unit]
Description=Tomcat Server
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
 
[Install]
WantedBy=multi-user.target

新增文件:

nano /etc/rc.local

内容:
#!/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.

export JAVA_HOME=/usr/jre
/usr/tomcat/bin/startup.sh
 
exit 0

添加权限:

chmod +x /etc/rc.local

设置到系统启动:

systemctl enable rc-local

启动脚本:

systemctl start rc-local.service

检查服务状态:

systemctl status rc-local.service