Bash

Bash script to measure bandwidth

I wrote a bash script to measure the amount of bandwidth, and to count the number of connections to the server, and used cron to run it once an hour. The results are written to a log. It works nicely, although I'm guessing my math is off a bit in calculating the bandwidth.

This was made to keep an eye on our web cam at my place of employment. It measures the bandwidth over 30 seconds during the run.


#!/bin/bash

CONN=`netstat -nt | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | sort -n | uniq | wc -l`
DATE=`date '+%D | %r'`

Bash script to delete files from sub directories

I needed to remove files from quite a few sub-directories in a directory, but couldn't remove the sub-directories. The attached script does just that.

Section:

Subscribe to RSS - Bash