random sleep duration in bash shell

Here is a quickie shell script (bash) tip. If you ever want to insert a random sleep/pause into a running script:

sleep $[ ( $RANDOM % 30 ) + 1 ]s

This will introduce a 1-10 second random sleep/pause in the script. Can be handy at times.

I put a cron job to call this script every 3 minutes:

Shell script to ping IP

To use it:

Or:

crontab:

Shell script to calculate file download speed

Sometimes I forgot to do nohup.out while creating download jobs.

If all you can do is ‘ls -al’, then this is the script to calculate file download speed.

Simply run: