gpt4 book ai didi

linux - 当我第二次运行它时,从特定行启动 bash 脚本

转载 作者:太空狗 更新时间:2023-10-29 11:40:37 26 4
gpt4 key购买 nike

当我第二次运行 bash 脚本时,有没有什么可以让我从特定行开始的?

    #!/bin/bash
#installed jq by using sudo apt-get install jq
# return indices and os,process
a=$(curl -XGET 'http://localhost:9200/_nodes/node01/stats/os,process?pretty=1')

#return just jvm
b=$(curl -XGET 'http://localhost:9200/_nodes/node01/stats/jvm?pretty=1')
c=$(curl -XGET 'http://localhost:9200/_nodes/node01/stats/indices?pretty=1')

d=$(curl -XGET 'http://localhost:9200/_nodes/node01/stats/thread_pool?pretty=1')

e=$(curl -XGET 'http://localhost:9200/_cluster/stats?pretty=1')

f=$(curl -XGET 'http://localhost:9200/_cat/nodes?v&h=uptime')
uptime=$(echo $f | cut -d' ' -f 2)
echo $uptime
echo $e >"parameters4.json"

echo $d > "parameters3.json"


echo $c > "parameters2.json"

echo $b

#uptime=$(cat servrtime.txt | grep uptime)

host=$(hostname -I)
echo $host

当我第二次运行它时,它必须从 host=$(hostname -I) 行开始,有什么办法吗??

最佳答案

就我个人而言,我不会让它过于复杂,也不会在执行一次性命令后触摸文件系统上某处的文件。

if [[ ! -f /some/file ]]; then
# your commands that should be executed only once
touch /some/file
fi

# the rest of the script

确保你触摸文件的某个地方不会被意外删除。

关于linux - 当我第二次运行它时,从特定行启动 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52662685/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com