写一个shell 脚本,反复执行sg_reset
时间: 2023-07-13 18:35:38 浏览: 79
好的,以下是一个简单的 shell 脚本,它将会反复执行 `sg_reset` 命令:
```bash
#!/bin/bash
while true; do
sg_reset /dev/sdX
sleep 1
done
```
请替换 `/dev/sdX` 为你想要执行 `sg_reset` 命令的设备名称。
你可以使用 `chmod +x script.sh` 命令来将其改为可执行文件,然后运行 `./script.sh` 来执行该脚本。
相关问题
写一个用shell脚本执行shell脚本
可以使用以下命令来执行一个shell脚本:
```shell
sh /path/to/script.sh
```
其中,`/path/to/script.sh`是要执行的shell脚本的路径。如果你想要在脚本中指定解释器,可以在脚本的第一行添加`#!/bin/bash`或`#!/bin/sh`等指令。
如果你想要在一个shell脚本中执行另一个shell脚本,可以使用以下命令:
```shell
sh /path/to/another_script.sh
```
或者,如果你想要在当前shell中执行另一个脚本,可以使用以下命令:
```shell
source /path/to/another_script.sh
```
写一个shell脚本,远程执行重启命令。
#!/bin/bash
# 远程执行重启命令脚本
# 定义远程主机IP地址和用户名
remote_host="192.168.1.100"
remote_user="root"
# 定义重启命令
restart_cmd="sudo reboot"
# 远程执行重启命令
ssh ${remote_user}@${remote_host} "${restart_cmd}"