当前位置:首页 > linux > 正文内容

配置机自启脚本地址/etc/rc.local ,在关机卡死 a stop job running for /etc/rc.local Compatibility (*s / no limit)

root3年前 (2021-01-07)linux1764

给自己的程序添加开机自启

写了个脚本添加,并把执行脚本命令添加到了卡机启动中/etc/rc.local 

(不是一个设置开机启动的好办法)

开机的时候存在失败,因为依赖的服务可能还没启动脚本就启动了 

只能在脚本最上面sleep一会了(全靠命)

接着就是令人头疼的问题,关机的时候界面卡死在a stop job running for  /etc/rc.local   Compatibility (*s / no limit)

各种写关机脚本关闭开启启动的程序,但是都没执行。(这个失败的方案参考https://my.oschina.net/bobchow/blog/812132

无奈放弃这个方式

正确的解决方式是在rc-local.service 的配置里面作文章

vim /lib/systemd/system/rc-local.service

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.


# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes

设置里面的TimeoutSec=30

这样关机就没啥问题了


当然正确的做法应该是

ExecStop = /**/**    stop

配置一个stop的脚本,在stop 脚本中关闭自己启动的程序



扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://zhiqiu.top/?id=70

分享给朋友:

相关文章

centos yum 找不到包

yum -y install epel-release安装依赖源...

测试xss公鸡

<script type="text/javascript">alert(123)</script>...

设置linux时间自动同步世界标准时间

因为主机时间没有自动同步有9.8s的误差。导致了出现负时间的问题首先手动校准时间ntpdate cn.pool.ntp.org开启时间自动更新服务systemctl start ntpd查看服务状态systemctl status ntpd...

Ubuntu apt-get彻底卸载软件包

apt-get的卸载相关的命令有remove/purge/autoremove/clean/autoclean等。具体来说:apt-get purge / apt-get –purge remove 删除已安装包(不保留配置文件)...

办公室千兆服务器之间scp的传输速度被限制在3MB/s

服务器之间拷贝文件是十分常见的操作但是有时候会遇见一个问题,拷贝的速度是相当的缓慢。遇见问题就开始分析问题影响网络网络传输有:服务器a和b、服务器网卡A和B、网线、交换机、路由器由于服务器a和b在同一台交换机不考虑路由器的因素查看服务器网卡...

centos切勿执行yum -y update

yum update 跟apt-get update 不一样centos的yum update相当于ubuntu的apt upgrade如果想用ubuntu的apt update,centos是yum makecache因为执行yum -y...