#!/bin/sh # Make a random number less than 10 delay=$((RANDOM % 10)) # Display it echo "delay=$delay" # Sleep for it sleep $delay # You can add "m" to sleep for minutes sleep ${delay}mNote that case matters, $random doesn't work.
Programming Tips - bash: How can I have a random delay in a bash script?
Date: 2016jun15
Language: bash
Q. bash: How can I have a random delay in a bash script?
A. Use $RANDOM and sleep like this: