reboot 关机时提示job is running for /etc/rc.d/rc.load Compatibility

/etc/rc.d/rc.load( 这个是/etc/rc.load软链过去的)中的内容引起的重启时关机失败。(也不是每次重启都失败,但是也会频繁发生)在rc.local里开机自动启动程序,但是关机重启时受到了影响。

/etc/rc.d/rc.load 文件中的命令不要放大于5s的命令,如果有,就用shell脚本,写到外边去。或者将/etc/rc.d/rc.load开机启动的时间设置长一些。

如果注释掉/etc/rc.d/rc.load的内容重启成功。

也可以看看/var/log/messages

 

通过这个http://bbs.qcloud.com/thread-11819-1-1.html 解决了这个问题

 

#!/bin/bash


#only centos need fix
if [ ! -f /etc/centos-release ]; then
    echo "this is not centos linux"
    exit 1
fi


#only centos7.0 7.1 7.2 need fix
osversion=`awk '{print $4}' /etc/centos-release`
if [ ${osversion} != '7.0.1406' ] && 
   [ ${osversion} != '7.1.1503' ] && 
   [ ${osversion} != '7.2.1511' ]; then
    echo "this is not centos7.0 7.1 7.2"
    exit 1
fi 


#create rc-local.service
cat > /etc/systemd/system/rc-local.service <<EOF
#  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.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target



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


#modify the default timeout of systemd
sed -i 's/#DefaultTimeoutStopSec=90s/DefaultTimeoutStopSec=30s/g' /etc/systemd/system.conf


systemctl daemon-reload


exit 0

 

 

 

这些还是放supervisor比较好,或者写一个service。简单的很
[Unit]
Description=服务名称
After=network.target


[Service]
Type=forking


ExecStart=完整的执行程序,例如:/usr/bin/licensing
ExecReload=软件停止命令,例如:/usr/bin/licensing -s stop
PrivateTmp=true


[Install]
WantedBy=multi-user.target

 

 

然后放在/usr/lib/systemd/system/下面

 

# 启动服务
systemctl daemon-reload
systemctl enable licensing.service
systemctl start licensing.service

 

systemctl -t service 查看所有服务的状态

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值