#!/bin/bash
# lsoflog
# (c) 2011-2017 SUSE Linux GmbH, Germany.
# (c) 2018-2019 SUSE LLC
# Author: L.Pinne.
# GNU General Public License v2. No warranty.
# Version: 0.1 2019-11-28
#
# shellcheck disable=SC2086
#

D=$(date +"%F %T")
E="/dev/null"
L=${1:-"/var/log/lsof.log"}
P=${2:-"+D/opt +D/srv"}
T=${3:-"42"}

lsof -n -P -X -w -S "$T" +fg +x ${P} 2>$E | while read -r; do
	echo "$D": "$REPLY"
done >>"$L"
#
