博客地址
服务器的配置服务总是莫名奇妙的消失,在没有解决前用开机脚本进行检测恢复。
之前centos的开机脚本和debian脚本有所不同,故此进行记录。
脚本
新建脚本移动至/etc/init.d文件夹下,并赋可执行权限
设置开机自启
update-rc.d xx.sh defaults
删除开机自启
update-rc.d -f xx.sh remove
脚本如下:
#!/bin/bash
echo '#!/bin/bash
#
### BEGIN INIT INFO
# Provides: recovery_conf
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network $time
# Should-Stop: $network $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: recovery toll.conf
### END INIT INFO
#
cd /root/itssky/bin
line=`cat toll.conf | wc -l`
if [[ $line -lt 70 ]];then
cp -f toll.conf~ toll.conf
this_pid=`pidof Its*`
if [ ! -z "$this_pid" ];then
kill -9 ${this_pid} && startx
fi
fi
' >/etc/init.d/recovery_conf.sh
chmod +x /etc/init.d/recovery_conf.sh
update-rc.d recovery_conf.sh defaults
cd /root/itssky/bin/
if [ ! -f "toll.conf~" ];then
cp toll.conf toll.conf~
fi
网友评论