5

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
2
  • 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?
    – user313992
    Jun 27, 2019 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, 2019 at 11:55

2 Answers 2

11

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.

1

Change this:

for i in {1..10}

to this:

for i in $(seq 10)

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

2

Not the answer you're looking for? Browse other questions tagged .