如何运行按顺序处理的多个 curl 请求? [英] How can I run multiple curl requests processed sequentially?

查看:22
本文介绍了如何运行按顺序处理的多个 curl 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我是一个大的 Unix 新手:

Assuming I'm a big Unix rookie:

  • 我每 15 分钟通过 cron 运行一次 curl 请求.

  • I'm running a curl request through cron every 15 minutes.

Curl 基本上用于加载给出一些参数的网页 (PHP),充当如下脚本:

Curl basically is used to load a web page (PHP) that given some arguments, acts as a script like:

curl http://example.com/?update_=1

我想要实现的是运行另一个脚本"使用这种卷曲技术,

What I would like to achieve is to run another "script" using this curl technique,

  • 每次运行其他脚本时
  • 在其他脚本运行之前

我已经读到 curl 在一个命令中接受多个 URL,但我不确定这是否会按顺序或并行"处理 URL.

I have read that curl accepts multiple URLs in one command, but I'm unsure if this would process the URLs sequentially or in "parallel".

推荐答案

它很可能会按顺序处理它们(为什么不直接测试它).但你也可以这样做:

It would most likely process them sequentially (why not just test it). But you can also do this:

  1. 制作一个名为 curlrequests.sh

像这样把它放在一个文件中:

put it in a file like thus:

curl http://example.com/?update_=1
curl http://example.com/?update_=3
curl http://example.com/?update_=234
curl http://example.com/?update_=65

  • 保存文件并使用 chmod 使其可执行:

    chmod +x curlrequests.sh
    

  • 运行您的文件:

  • run your file:

    ./curlrequests.sh
    

  •    /path/to/file/curlrequests.sh
    

    作为旁注,您可以使用 && 链接请求,如下所示:

    As a side note, you can chain requests with &&, like this:

       curl http://example.com/?update_=1 && curl http://example.com/?update_=2 && curl http://example.com?update_=3`
    

    并使用&并行执行:

       curl http://example.com/?update_=1 & curl http://example.com/?update_=2 & curl http://example.com/?update_=3
    

    这篇关于如何运行按顺序处理的多个 curl 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆