BASH_SRV Telegram 139
Мониторинга логов в реальном времени

Иногда нужно следить за логами, но обычный tail -f не всегда удобен. Ниже накидал скрипт, который подсвечивает ошибки и предупреждения разными цветами:


#!/bin/bash
# автор: https://www.tgoop.com/bash_srv

LOGFILE="/var/log/syslog"

tail -Fn0 "$LOGFILE" | \
while read line; do
if echo "$line" | grep -q "ERROR"; then
echo -e "\e[31m$line\e[0m" # красный для ошибок
elif echo "$line" | grep -q "WARN"; then
echo -e "\e[33m$line\e[0m" # жёлтый для предупреждений
else
echo "$line"
fi
done


📌 Можно изменить путь к файлу лога (LOGFILE) и ключевые слова (ERROR, WARN) под свои нужды.
Очень удобно, когда нужно быстро отследить проблемные записи в логах.

👉@bash_srv
👍10



tgoop.com/bash_srv/139
Create:
Last Update:

Мониторинга логов в реальном времени

Иногда нужно следить за логами, но обычный tail -f не всегда удобен. Ниже накидал скрипт, который подсвечивает ошибки и предупреждения разными цветами:


#!/bin/bash
# автор: https://www.tgoop.com/bash_srv

LOGFILE="/var/log/syslog"

tail -Fn0 "$LOGFILE" | \
while read line; do
if echo "$line" | grep -q "ERROR"; then
echo -e "\e[31m$line\e[0m" # красный для ошибок
elif echo "$line" | grep -q "WARN"; then
echo -e "\e[33m$line\e[0m" # жёлтый для предупреждений
else
echo "$line"
fi
done


📌 Можно изменить путь к файлу лога (LOGFILE) и ключевые слова (ERROR, WARN) под свои нужды.
Очень удобно, когда нужно быстро отследить проблемные записи в логах.

👉@bash_srv

BY Bash Советы




Share with your friend now:
tgoop.com/bash_srv/139

View MORE
Open in Telegram


Telegram News

Date: |

bank east asia october 20 kowloon As of Thursday, the SUCK Channel had 34,146 subscribers, with only one message dated August 28, 2020. It was an announcement stating that police had removed all posts on the channel because its content “contravenes the laws of Hong Kong.” How to Create a Private or Public Channel on Telegram? The creator of the channel becomes its administrator by default. If you need help managing your channel, you can add more administrators from your subscriber base. You can provide each admin with limited or full rights to manage the channel. For example, you can allow an administrator to publish and edit content while withholding the right to add new subscribers. The SUCK Channel on Telegram, with a message saying some content has been removed by the police. Photo: Telegram screenshot.
from us


Telegram Bash Советы
FROM American