Monitor TCP Connection in bash regularly

Simple one, it monitor regularly the Established connection to file:


#!/bin/bash

NOW=$(date +"%d-%m-%Y-%H-%M-%S")
LOG="/tmp/netstat.log"
while true;
do
echo ${NOW} >> ${LOG}
netstat -anp | grep '443' | grep 'ESTABLISHED' >> ${LOG}
echo done >> ${LOG}
sleep 3
done

Leave a Reply

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