Is there a cheap way to monitor a log file like tail -f log.txt, then if something like [error] appears, execute a command?
tail -f log.txt
[error]
Thank you.
tail -fn0 logfile | while read line ; do echo "$line" | grep "pattern" if [ $? = 0 ] then ... do something ... fi done
1.4m articles
1.4m replys
5 comments
57.0k users