Sleep less than 1 second | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Sleep less than 1 second

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-23-2005
bjorno bjorno is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 22 November 2010, 5:04 AM EST
Location: Sweden
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Sleep less than 1 second

Does anyone know a way to sleep less than 1 second?
Sometimes when I write scripts that iterates a loop many times it would be
nice to slow things down, but sometimes 1 second is too much.
Sponsored Links
    #2  
Old 08-23-2005
sysera sysera is offline
Registered User
 
Join Date: Feb 2004
Last Activity: 8 October 2009, 9:25 AM EDT
Posts: 92
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by bjorno
Does anyone know a way to sleep less than 1 second?
Sometimes when I write scripts that iterates a loop many times it would be
nice to slow things down, but sometimes 1 second is too much.
If your system has "usleep" this allows you to sleep in increments of milliseconds instead of seconds.
Sponsored Links
    #3  
Old 08-23-2005
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 31 October 2014, 9:07 AM EDT
Location: NM
Posts: 10,254
Thanks: 285
Thanked 803 Times in 747 Posts
usleep in C code.
    #4  
Old 08-24-2005
bjorno bjorno is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 22 November 2010, 5:04 AM EST
Location: Sweden
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
I dont have usleep in my system, which is AIX 5.2.
Is there a compiled version of usleep to download. I think I'm not able
to compile it myself.
Sponsored Links
    #5  
Old 08-24-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 28 October 2014, 3:35 PM EDT
Location: Ashburn, Virginia
Posts: 9,930
Thanks: 64
Thanked 437 Times in 261 Posts
If you have perl try:

perl -e 'select(undef,undef,undef,.1)'

That .1 means .1 seconds.
Sponsored Links
    #6  
Old 08-24-2005
bjorno bjorno is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 22 November 2010, 5:04 AM EST
Location: Sweden
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Perderabo
If you have perl try:

perl -e 'select(undef,undef,undef,.1)'

That .1 means .1 seconds.
That works. It is hard to meassure the time but it is definitely less than 1 second.

Thanks a lot.
Sponsored Links
    #7  
Old 08-24-2005
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 31 October 2014, 9:07 AM EDT
Location: NM
Posts: 10,254
Thanks: 285
Thanked 803 Times in 747 Posts
IT's not hard to measure the elapsed time:
Put Perderabo's code in a script, call it usleep.sh

Code:
time usleep.sh

will give you something like this:

Code:
kcsdev:/home/jmcnama> time usleep.sh

real    0m0.18s
user    0m0.03s
sys     0m0.05s

real is the elapsed time.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Wrapping 'sleep' with my 'resleep' function (Resettable sleep) deckard Shell Programming and Scripting 5 09-28-2009 01:58 PM
sleep working meetbhattu UNIX for Advanced & Expert Users 2 10-29-2007 05:05 PM
Sleep under one second Scoogie Shell Programming and Scripting 5 08-14-2002 08:10 AM
sleep Anna UNIX for Dummies Questions & Answers 5 07-10-2001 11:52 PM



All times are GMT -4. The time now is 09:31 AM.