Is there a cheap way to monitor a log file like tail -f log.txt
, then if something like [error]
appears, execute a command?
Thank you.
Like any other OS, you can use certain commands to see Linux log files. Linux logs will display with the command cd/var/log. Then, you can type ls to see the logs stored under this directory. One of the most important logs to view is the syslog, which logs everything but auth-related messages.
tail -fn0 logfile | \ while read line ; do echo "$line" | grep "pattern" if [ $? = 0 ] then ... do something ... fi done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With