4

This question already has an answer here:

I am using this script on router using Entware to check response of website every 15 min. It only runs once and terminates after the first 15 mins. Why?

#! /bin/sh

for i in {1..10}
do  
  date >> webresp.csv
  curl -w 'Testing Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null www.google.com | tee -a webresp.csv
  sleep 900
done

marked as duplicate by muru, mosvy, Kusalananda shell-script Jun 27 at 6:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    If want your script to check the server every 15 minutes, why run it only 10 times? Do you use another script to start it every 2 and a half hours? Why not use cron? – mosvy Jun 27 at 5:22
  • @mosvy The 10 times was only for test run..I would adjust according to my needs when script works. Will try as cron as well but had problems before..confusing quotation marks! – kielan Jun 27 at 11:55
0

Change this:

for i in {1..10}

to this:

for i in $(seq 10)

...and the script should then work as expected.

10

You are using #! /bin/sh. {1..10} is a bash extension, not standard shell. Bash would expand {1..10} into 10 words,for a standard shell it is just one word.

Not the answer you're looking for? Browse other questions tagged or ask your own question.