Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2016jun15 Language: bash Q. How can I have a random delay in a bash script? A. Use $RANDOM and sleep like this:#!/bin/sh # Make a random number less than 10 delay=$((RANDOM % 10)) # Display it echo "delay=$delay" # Sleep for it sleep $delayOr simply:sleep $((RANDOM % 10))Note that case matters, $random doesn't work.
Add a commentSign in to add a comment