Quick DD Script for Generating Files

Random

Sometimes it can be useful to generate some files, so you can watch activity, I created this script for this use-case when performing storage updates, I can run this to generate some activity which is made visible to the screen so you can see if and when either expected or unexpected pauses take place. Its a simple BASH script you can run as follows:

./check_script_dd_local.sh /tmp/ddtest

And the code is:

#!/bin/bash

# Example Command: ./check_script_dd_local.sh /tmp/ddtest
# Runs the script and generates the random files within the /tmp/ddtest directory.

local_path=$1

while :
do
        date

        for n in {1..1000}; do
          echo -n "Creating a random file called random.img."$n" in "$local_path"....."
          dd if=/dev/urandom of=$local_path/random.img.$n count=10 bs=8K
        echo "Done!"
done
        sleep 1
        echo "Deleting the random files...."
        rm $local_path/random.img.*

        sleep 1
done

Leave a Reply

Your email address will not be published. Required fields are marked *