Bash scripting web tests with ‘wget’

21 March 2014, 6:47 pm

Did you know you can use the command line wget tool to perform simple tests on your web site?

In a Linux environment combining the programmatic capabilities of a Bash (Bourne Again SHell) script with wget is pretty easy and allows you to carry out basic load and performance tests. These tests could be run directly from your local machine or any other remote machine or VM with a Bash shell and wget, which is pretty much any Linux distro.

When I recently wanted to check whether a problem, where my web servers died under load, was resolved I wrote the following simple script:

You can save this as wload.sh and execute it in a Linux environment using the command:
./wload.sh [your URL under test] [no. concurrent requests to fire]

I think these kind of scripts are pretty neat, and I believe there is definitely a place for the ‘humble’ Bash script in the development process every now and again. You can do a lot more with Bash than just fire off requests at a page and as it is essentially a programming language it can be very powerful in the right hands.