千家信息网

Debian增加开机启动

发表于:2024-10-01 作者:千家信息网编辑
千家信息网最后更新 2024年10月01日,1、增加服务文件vi /etc/systemd/system/rc-local.service[Unit]Description=/etc/rc.localConditionPathExists=/e
千家信息网最后更新 2024年10月01日Debian增加开机启动

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

转载于:http://mingli.muhuolong.cn/

0