您的位置:首页 > 其它

某个开机自启的服务无法启动导致系统无法启动故障解决

2017-05-11 22:22 369 查看
cd /etc/init.d/
vim testsrv
输入以下内容
#!/bin/bash
#chkconfig:2345 99 00
#description:this service is used for test
case $1 in
start)
echo 'the service is started'
touch /root/testsrv
;;
stop)
echo 'the service is stopped'
rm -f /boot/testsrv
;;
status)
[ -f /boot/testsrv ] && echo 'service testsrv is running...'||echo 'service testrv is stopped'
;;
*)
echo 'Usage start|stop|status'

注意#chkconfig:2345 99 00这里开机启动的序号不能大于99
#给执行权限
chmod +x testsrv
chkconfig --add testsrv
chkconfig testsrv --level 1 on
修改启动时间
reboot
#!/bin/bash
#chkconfig:12345 00 00
#description:this service is used for test
case $1 in
start)
echo 'the service is started'
sleep 100000
touch /root/testsrv
;;

由于启动序号设置太小,网络服务还没起来,无法连接xshell,而单用户模式也设置了开机启动,所以需要按照如下方法修复
开机按回车进入内核选则项
按a 在quite后添加 init=/bin/bash(默认为/sbin/init)
此时开机进入bash以后根目录是以只读方式挂载的,需要重新挂载
mount -o remount,rw /
chkconfig --level  12345 testsrv off
exit
reboot
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐