views:

31

answers:

2

Assuming I'm a big unix rookie, - I'm running a curl request through cron every 15 minutes. - Curl basically is used to load a web page (php) that given some arguments, acts as a script like:

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

What I would like to achieve is to run another "script" using this curl technique, - every time the other script is run - before the other script is run

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

A: 

Write a script with two curl requests in desired order and run it by cron, like

#!/bin/bash
curl http://mysite.com/?update_=1
curl http://mysite.com/?the_other_thing
mbq
Thanks everyone!
Riccardo
Give a vote or accept an answer!
mbq
+2  A: 

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

1) make a file called curlrequests.sh 2) put it in a file like thus:

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

3) save the file and make it executable with chmod:

chmod +x curlrequests.sh

4) run your file:

./curlrequests.sh

or

/path/to/file/curlrequests.sh

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

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

And execute in parallel using &:

curl http://mysite.com/?update_=1 & curl http://mysite.com/?update_=2 & curl http://mysite.com/?update_=3
Timothy Baldridge
Riccardo
Yes, in most cases they will, but if one of them should end up with error (return value other than 0), the following will not be executed.
mbq
that's perfect for me. Thanks!
Riccardo