Run cURL command every 5 seconds

Archit Arora picture Archit Arora · Jul 1, 2014 · Viewed 31.3k times · Source

This is the command that I want to run -

curl --request POST --data-binary @payload.txt --header "carriots.apiKey:XXXXXXXXXXXXXXXXXXXX" --verbose http://api.carriots.com/streams

This basically sends a data stream to a server.

I want to run this command every 5 seconds. How do I achieve this?

Answer

Jayesh Bhoi picture Jayesh Bhoi · Jul 1, 2014

You can run in while loop.

while sleep 5; do cmd; done

Edit:

If you don't want to use while..loop. you can use watch command.

watch -n 5 cmd