不需要脚本
* * * * * for i in {0..59}; do curl wwww.baidu.com & sleep 1; done
简单的,可以用:
while sleep 1; do curl -i http://xxx...xxxx/test; done
接下来,你可能会考虑如何在后台运行,有几个选择:
nohup
init.d
systemctl
supervisor
这儿的解答可以帮助你。
crontab的精度是一分钟 所以想到直接crontab这条路已经死了。
只能写个shell。 shell sleep的时间为一秒
可以参考
crontab实现
How to get a unix script to run every 15 seconds?
目前了解到秒级的处理方案有两个。
第一:写一个死循环脚本:
while(true){
do command
}
第二:就是@白菜1031提的那个方法写60行crontab
* * * * * sleep 1s;curl http://www.baidu.com
* * * * * sleep 2s;curl http://www.baidu.com
...
* * * * * sleep 59s;curl http://www.baidu.com
大概就是这个意思,你可以写成一个脚本来执行。
在脚本中使用循环,每次循环sleep 1s;然后执行curl,循环60次。然后每分钟执行一次这个脚本就可以实现每秒请求一次了。
用脚本for循环去执行。否则如果你要修改秒数间隔,或者修改执行内容,你还一行一行改么。
app.sh
step=1
for (( i=0;i<60;i=(i+$step) )); do
curl http://www.google.com &
sleep $step
done
crontab -e
* * * * * sh /app.sh