麒麟系统下重启测试的方法以及测试脚本

1.在/lib/systemd/system目录下放一个reboot-test.service:

[Unit]
Description=reboot-test
After=network.target

[Service]
User=root
Group=root
ExecStart=/root/reboot-test.sh

[Install]
WantedBy=multi-user.target

2.写一个reboot的脚本,放在系统的/root目录下,脚本代码如下:

#!/bin/bash
cntfile="/root/cntfile";
logfile="/root/logfile";
let totalcnt=500;              //测试的次数
let pingcnt=0;
if [ ! -f "$cntfile" ]; then
    cnt=0; 
else
    let cnt=`cat "$cntfile"`;
fi

if [ -z $cnt ]; then
    cnt=0; 
fi

if [ $cnt -eq 0 ]; then
    if [ -f $logfile ]; then
        rm $logfile;
    fi
    touch $logfile;
fi

if [ $cnt -eq $totalcnt ];then
    exit 0;
fi

let cnt=$cnt+1;
echo $cnt > $cntfile;
echo "-----------test count is $cnt-------------" >> $logfile;
lspci | grep Eth >> $logfile

sleep 20;                   //每次重启等待的时间
reboot

3.更改reboot-test.sh的权限:

chmod 777 reboot-test.sh

4.开始测试的命令:

systemctl enable reboot-test
systemctl start reboot-test

5.测试过程中,如果想要停止,可以使用下面的命令来停止测试:

systemctl stop reboot-test
systemctl disable reboot-test

这里可以更改上面的reboot脚本,因为之前写的重启过程中只等待20s,可能来不及输入这两条命令,可以根据自己的情况适当提高等待的时间。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值