Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Asu

macrumors member
Original poster
Apr 28, 2006
69
7
Hello Mavens,

I need help (as in "Pretty please tell me exactly how to do it...") with the following task.

Code:
while running in the background
(at random intervals (between 0.5 and 5 minutes)) (do a command)

that's it!

TIA and Merry (OS)Xmas

Asu
 
Code:
until [ 1 -eq 2 ]
do
  ....
  let "sleepval = $RANDOM % 271 + 30"
  sleep $sleepval
done

No guarantees, this was written on my phone. The principle should be clear, though. In ...'s place you put what you want to run, then get a random value from 0 to 270, then add 30. This is the amount of time in seconds to sleep.

There is quite likely a better way, but I think this should work.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.