美文网首页
Debian/Ubuntu启用/etc/rc.local增加开机

Debian/Ubuntu启用/etc/rc.local增加开机

作者: blueboyggh | 来源:发表于2022-03-06 13:05 被阅读0次

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\

相关文章

网友评论

      本文标题:Debian/Ubuntu启用/etc/rc.local增加开机

      本文链接:https://www.haomeiwen.com/subject/zezirrtx.html