【问题标题】:Is there a way to loop a specific part of bash script有没有办法循环bash脚本的特定部分
【发布时间】:2022-01-27 05:13:55
【问题描述】:

这是我找到的代码,我想从 cpu=$(</sys/class/thermal/thermal_zone0/temp) 开始每 2 分钟循环一次这些命令。

    #!/bin/bash
# Script: Check-Temp.sh
# Purpose: Display the ARM CPU and GPU  temperature of Raspberry Pi 2/3
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => $(/usr/bin/vcgencmd measure_temp)"
echo "CPU => $((cpu/1000))'C"

【问题讨论】:

  • 你可以创建一个只包含你需要的行的新 bash 脚本。
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: bash loops shell


【解决方案1】:

执行您的代码,然后等待 2 分钟

#!/bin/sh  
while true  
do  
  ##your code here  
  sleep 120  
done

【讨论】:

    猜你喜欢
    • 2020-05-08
    • 1970-01-01
    • 1970-01-01
    • 2019-10-03
    • 1970-01-01
    • 2020-01-08
    • 2021-02-04
    • 2016-03-18
    • 2010-10-06
    相关资源
    最近更新 更多