发布于 1970-01-01 08:00
  • 6 个回答
    • 不需要脚本

      * * * * * for i in {0..59}; do curl wwww.baidu.com & sleep 1; done
      2022-11-12 01:56 回答
    • 简单的,可以用:

      while sleep 1; do curl -i http://xxx...xxxx/test; done
      

      接下来,你可能会考虑如何在后台运行,有几个选择:

      • nohup

      • init.d

      • systemctl

      • supervisor

      这儿的解答可以帮助你。

      2022-11-12 01:56 回答
    • crontab的精度是一分钟 所以想到直接crontab这条路已经死了。
      只能写个shell。 shell sleep的时间为一秒
      可以参考
      crontab实现
      How to get a unix script to run every 15 seconds?

      2022-11-12 01:56 回答
    • 目前了解到秒级的处理方案有两个。
      第一:写一个死循环脚本:

      while(true){
      do command
      }
      
      

      第二:就是@白菜1031提的那个方法写60行crontab

      2022-11-12 01:56 回答
    • * * * * * 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次。然后每分钟执行一次这个脚本就可以实现每秒请求一次了。

      2022-11-12 01:56 回答
    • 用脚本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
      2022-11-12 01:56 回答
    撰写答案
    今天,你开发时遇到什么问题呢?
    立即提问
    PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
    Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有