遇到的问题:sleep: missing operand Try 'sleep --help' for more information. 【睡眠:缺少操作数有关更多信息,请尝试“sleep--help”。】
方式一:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
step=5 #间隔的秒数,不能大于60
for (( i = 0; i < 60; i=(i+step) )); do
curl -sS --connect-timeout 10 -m 60 'http://www.baidu.com/' #修改成自己的网址连接
echo "----------------------------------------------------------------------------"
endDate=`date +"%Y-%m-%d %H:%M:%S"`
echo "★[$endDate] Successful"
echo "----------------------------------------------------------------------------"
sleep $step
done
exit 0
方式二:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin
step=10 #间隔的秒数,不能大于10
for (( i = 0; i < 60; i=(i+step) )); do
curl http://www.baidu.com
sleep $step
done
exit 0
参考链接:Shell变量
原文链接:宝塔添加秒级定时任务
网友评论