Checker

Angelegt Dienstag 25 Juli 2023



#!/bin/bash
# checker - show open connections


if [[ $1 ]]
then

case $1 in
-*) echo "checker: show & log open udp|tcp ports. Logfile is ~/checker.log";
echo "usage: checker [n] - optional n is the time in seconds between updates. if n is not specified 2 is used.";
echo "related commands: newchecker - delete logfile, checkerlog - show checker.log";;
*) clear ; while true ; do date | tee -a ~/checker.log ; sudo lsof -i | tee -a ~/checker.log ; sleep $1 ; clear ; done;;
esac
else
clear ; while true ; do date | tee -a ~/checker.log ; sudo lsof -i | tee -a ~/checker.log ; sleep 2 ; clear ; done
fi
exit 0


(noch eleganter aber ohne Datum ist natürlich die Verwendung das 'watch'-Befehls:)


watch -n 2 "date |sudo lsof -i | tee -a ~/checker.log"