我需要每 30 分钟至少向 locahost 运行一次curl 请求。所以命令将是curl http://localhost:8080
。
这里的问题是,我想在5分钟到30分钟之间随机选择一个时间,然后执行curl命令。伪代码可能如下所示
while(true)
n = random number between 5-30
run curl http://localhost:8080 after 'n' minutes
详细的答案会很好,因为我对linux了解不多。
最佳答案
while true; do
sleep $(((RANDOM%25+5)*60))
curl http://localhost:8080
done
关于Linux:每 50 分钟随机运行一次命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45746542/