LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-01-2012, 04:21 AM   #1
ali2011
Member
 
Registered: Nov 2011
Location: USA, CA
Distribution: Ubuntu+Fedora
Posts: 80

Rep: Reputation: Disabled
Timing a Command in a Loop:


How can I set a time limit of 10s for each moment I execute the command "iperf" in the until loop below? (I don't want the iperf to stay with a host more than 10s)
Code:
while read loop; do 
TRIES=1;
until ./iperf -c $loop -w 0.5M -n 2M > $loop && grep -q "size" $loop.iperf; do  
if [ "$TRIES" -ge 1 ]; then 
echo "+ Inner loop: $loop"; 
break;
fi;
echo "+ Inner loop: $loop";
TRIES=`expr $TRIES + 1`;
done;
done < list
 
Old 01-01-2012, 08:11 AM   #2
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Hi.

From `apt-cache show iperf':
Quote:
Features:
...
* Options can be specified with K (kilo-) and M (mega-) suffices.
* Can run for specified time, rather than a set amount of data to transfer.
* Picks the best units for the size of data being reported.
...
From `man iperf':
Quote:
-t, --time n
time in seconds to transmit for (default 10 secs)
Hope this helps.
 
Old 01-01-2012, 11:26 AM   #3
ali2011
Member
 
Registered: Nov 2011
Location: USA, CA
Distribution: Ubuntu+Fedora
Posts: 80

Original Poster
Rep: Reputation: Disabled
I know there is a -t option in iperf, if you read carefully I use the -n option for a particular reason so this -t doesn't work with me.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash command execution timing weird or unrar shuts down script prematurely porphyry5 Programming 2 11-15-2011 12:20 PM
[SOLVED] timing out a wget command in a script Cerephim Linux - Server 3 01-12-2011 09:49 AM
how to loop a command? adamrosspayne Linux - Newbie 15 06-23-2006 06:33 PM
how to start timing and print the timing result on portions of java codes ?? alred Programming 2 05-15-2006 10:00 AM
SSH remote command not timing out tajsss Other *NIX 5 04-28-2005 06:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration