UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 16th, 2006, 08:25 AM
robbrown robbrown is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 353 robbrown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 32 m 55 sec
Reputation Power: 7
Arrow Shell Script Waiting for a random amount of time

I need to insert a wait (pause the script) command for a random amount between 1 minuite and 1 hour of time before running the next command.

Example:

run this
run that
wait (random time)
run another


Can anyone help me with this? Any help is greatly appreciated.

Reply With Quote
  #2  
Old March 16th, 2006, 09:27 AM
SimonJM SimonJM is online now
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 762 SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 21 h 55 m 51 sec
Reputation Power: 336
The sleep command will do it for you, you just need to provide it with a suitable random number.

Reply With Quote
  #3  
Old March 16th, 2006, 09:39 AM
stanleypane's Avatar
stanleypane stanleypane is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Baltimore, MD
Posts: 208 stanleypane User rank is Sergeant (500 - 2000 Reputation Level)stanleypane User rank is Sergeant (500 - 2000 Reputation Level)stanleypane User rank is Sergeant (500 - 2000 Reputation Level)stanleypane User rank is Sergeant (500 - 2000 Reputation Level)stanleypane User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 7 h 4 m 19 sec
Reputation Power: 21
How about:

Code:
#!/bin/sh

seconds=$(( (RANDOM%60+1)*60 ))

sleep $seconds
Comments on this post
robbrown agrees: That worked perfectly! Thank-you very much!

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Shell Script Waiting for a random amount of time


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT