写一个shell脚本,在shell脚本循环insmod、rmmod mt_speedtest.ko

在Linux操作系统中,可以使用以下方法编写shell脚本,用以循环插入(most commonly with insmod)和移除(rmmod)“mt_speedtest.ko”模块:首先,使用touch命令创建一个名为script.sh的新文件,然后打开它以输入内容,以下是一个简单的脚本示例:

#!/bin/bash 

module="mt_speedtest"
modulefile="/path/to/mt_speedtest.ko" 

for i in {
    
    1..10}  #这个范围可以根据你的需求改变
do
    echo "Inserting..."
    insmod $modulefile
    sleep 1  # 这里的sleep是为了给模块插入留出时间,可以根据需要进行修改
    echo "Removing..."
    rmmod $module
    sleep 1  # 这里的sleep是为了给模块移除留出时间,可以根据需要进行修改
done

可以使用下面命令让脚本具有可执行权限

chmod +x script.sh  # 让脚本具有可执行权限

然后使用命令执行该脚本

sh script.sh

猜你喜欢

转载自blog.csdn.net/qq_41483419/article/details/132895165
今日推荐