inotify-tail/monitor.sh
Ilya Ivanov 295f1cd45f
Some checks failed
Build and publish Docker image / build-push (push) Has been cancelled
Fix cpu usage (#2)
* mon script low cpu usage

* fix path

* rm intorify-utils
2024-09-23 15:01:32 +03:00

19 lines
346 B
Bash
Executable File

#!/bin/bash
# directory to monitor
MONITOR_DIR=${1:-"/var/log/audit"}
process_file() {
local file="$1"
iconv -s -t utf-8 $file
rm -f "$file"
}
export -f process_file
while (true); do
find ${MONITOR_DIR} -type f -exec bash -c 'process_file "$0"' {} \;
find "${MONITOR_DIR}" -mindepth 1 -empty -mmin +2 -delete -type d
sleep 5
done