How Do You Generate a 100 GB Log File?

Problem scenario
You want to generate a large log file to use later on (e.g., for the Elastic Stack or Splunk). How do you create a 100 GB log file?

Solution
Find an example log to base the generation off. Run these commands to find a log that you would want to copy its format:

cd /var/log
ls -lh --sort=size
sudo tail foobar # where foobar is the name of the log file you want to sample

2. Draft a script like this, but substitute "foobar" with the name of the file you want to change.

for i in {1..1000}
  do cat /var/log/foobar >> /tmp/newfile.log
done

# The new file will be 1,000 times as large as the original log file.  
# You will want to change 1000 to a different value so the resulting file is 100 GB.

3. Name the script "cool.sh" and run it: bash cool.sh

Leave a comment

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