gpt4 book ai didi

linux - 使 curl 命令 shell 脚本 centOS 超时

转载 作者:太空宇宙 更新时间:2023-11-04 10:07:00 25 4
gpt4 key购买 nike

checkServer(){
response=$(curl --connect-timeout 10 --write-out %{http_code} --silent --output /dev/null localhost:8080/patuna/servicecheck)

if [ "$response" = "200" ];
then echo "`date --rfc-3339=seconds` - Server is healthy, up and running"
return 0
else
echo "`date --rfc-3339=seconds` - Server is not healthy(response code - $response ), server is going to restrat"
startTomcat
fi
}

在这里,我想使 curl 命令超时,但它不起作用。在centos7 Shell scrit中。我只需要做的就是使 curl 命令超时 错误代码是 curl:选项 --connect-timeout=: 未知

最佳答案

checkServer(){
response=$(curl --max-time 20 --connect-timeout 0 --write-out %{http_code} --silent --output /dev/null localhost:8080/patuna/servicecheck)

if [ "$response" = "200" ];
then echo "`date --rfc-3339=seconds` - Server is healthy, up and running"
return 0
else
echo "`date --rfc-3339=seconds` - Server is not healthy(response code - $response ), server is going to restrat"
startTomcat
fi
}

关于linux - 使 curl 命令 shell 脚本 centOS 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51853040/

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