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

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

root4年前 (2021-01-07)linux2550

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

写了个脚本添加,并把执行脚本命令添加到了卡机启动中/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

Bash
#  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

这样关机就没啥问题了

当然正确的做法应该是

Bash
ExecStop = /**/**    stop

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

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

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

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

相关文章

How to remotely monitor hosts over Telnet and SSH [Tutorial]

python ssh登录服务器In this tutorial, you will learn how to carry out basic configurations on a server with Telnet and SSH co...

mvware的NAT网络模式设置和端口映射

mvware的NAT网络模式设置和端口映射

在日常众多的虚拟机使用中,VMware的使用还是简单粗暴的。但是个人觉得有点重了,这都是题外话。当我们建立好我们的虚拟主机时,可能会遇见没有网络。网络模式常见的:桥接模式和NAT模式桥接模式很好理解就是跟宿主主机一样的网络情况。NAT模式比...

centos的新主机配置网络

centos的新主机配置网络

背景:公司因项目开发需要购置了两台主机。因为配置网络的大哥又是不在公司,但是又着急使用新主机。(旧的已经卡成狗腿了)急需解决问题,首先电脑刚插入网线又问题,不亮。只有一个网卡亮但是并不是Internet的网卡。其他四个网卡插入均不亮。换个网...

服务查看启动

服务启动、停止和重启service   xxx  start  service   xxx  stopservice   xxx ...

Python2 的Popen在docker中执行会挂起主进程

python2.7因业务需求。要把程序放入到docker容器中但是在docker执行的时候程序出现异常缓慢的情况检查函数执行情况发现当第一个线程执行到popen的时候会导致所有线程的挂起p1 = subprocess.P...

git 忽略文件不起作用 .gitignore

git rm -r --cached . git add .   git commit -m "update .gitignore"  git status查看是否是"working di...