I have this in the system logs:
Feb 27 02:53:51 Latitude-E6430 rsyslogd: action up 7
Feb 27 02:53:51 Latitude-E6430 rsyslogd: action down B
Feb 27 02:53:51 Latitude-E6430 rsyslogd: action up U
....etc
I want to make a script that is monitoring the logs full time as a service, but I don't know how to do the condition.
1 - That when you read, line by line, store it in a variable.
2 - read variable if it finds in the line, the words [rsyslogd] and [7] it shows [echo "Found" ]
It would be a loop to read the file line by line, looking for that pattern of words.
Example Script
path_full_log="/home/full.log"
function reader_time_real(){
while read full_log; do
chek7=$(cat $full_log | grep "rsyslogdd" | grep 7 )
if [[ $? = 0 ]]; then
echo "Found 7";
fi
chekB=$(cat $full_log | grep "rsyslogdd" | grep B )
if [[ $? = 0 ]]; then
echo "Found B";
fi
done < $path_full_log
}
cat $full_log
forecho $full_log
– BurstBass BurstBass Feb 28 '22 at 04:56