I would like to generate random numbers for "x" amount of time, but I'm not sure how to make it run for x amount of time (like 2 minutes for example).


Bah, nvm.. I figured it out lol.. This is my solution


# Generate random numbers for "X" amount of time.
TIMER='2m' # Default (2m) = 2 minutes
timeout -sHUP ${TIMER} bash -c 'while [ 0 ]; do echo "${RANDOM}"; done'


while true; do echo "$RANDOM"; done & sleep 2m; kill %1

It's a little bet less typing, and supports any time parameter that your local version of sleep supports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.