Comments on: Swatchdog – Simple Log File Watcher in Real-Time in Linux https://www.tecmint.com/swatch-linux-log-file-watcher/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Fri, 12 Feb 2021 09:17:28 +0000 hourly 1 By: Bernd https://www.tecmint.com/swatch-linux-log-file-watcher/comment-page-1/#comment-1433873 Fri, 12 Feb 2021 09:17:28 +0000 https://www.tecmint.com/?p=30180#comment-1433873 Hello,

The call with --Daemon must be made with -c.

old: $ swatchdog ~ / swatch / secure.conf -t / var / log / secure --daemon
correct: $ swatchdog -c ~ / swatch / secure.conf -t / var / log / secure --daemon 

Otherwise he will not find the config file

]]>
By: nnsense https://www.tecmint.com/swatch-linux-log-file-watcher/comment-page-1/#comment-1306355 Sun, 15 Dec 2019 01:37:57 +0000 https://www.tecmint.com/?p=30180#comment-1306355 About the above discussion, swatchdog can be reloaded automatically by using `--restart-time=`, and then you might add `--tail-args` to pass `-T -n1` to force tail to reload a non-existent file (tailing only one line at a time).

`swatch --awk-field-syntax --tail-args "-n1 -F" --restart-time=00:00 /opt/blackboard/logs/tomcat/stdout-stderr-$(%Y%m%d).log`

]]>
By: Aaron Kili https://www.tecmint.com/swatch-linux-log-file-watcher/comment-page-1/#comment-1020383 Thu, 02 Aug 2018 16:24:25 +0000 https://www.tecmint.com/?p=30180#comment-1020383 In reply to Rosalind Benoit.

@Rosalind

“One thing I thought of would be to put the swatch command in its own script which uses variables to define the right filename (ex. dateString={date +”%m-%d”//[-]/} tailString= ‘/opt/blackboard/logs/tomcat/stdout-stderr’+$dateString+’.log’) and then run that swatchdog script every day.”

This is the possible solution, and you have to deal with the system overhead, because as long as your threaded java app continues to run, then the swatchdog script also needs to continue running to watch stuck threads. The simple idea is continuous monitoring of a file using swatchdog, this definitely causes system overhead.

]]>
By: Rosalind Benoit https://www.tecmint.com/swatch-linux-log-file-watcher/comment-page-1/#comment-1020234 Wed, 01 Aug 2018 23:06:56 +0000 https://www.tecmint.com/?p=30180#comment-1020234 I just started using Swatch(dog) today on rhel and am psyched as I was originally going to have to reinvent the wheel here. Can you help me with one thing? I need to tail a specific logfile and watch for a string indicating that there may be stuck threads in my threaded java app.

Then I’ll execute a script to generate thread dumps if the string is found. All good, but the only problem is, the name of the logfile changes every day, as the current date is appended to the filename. So what I want is to be able to add:

swatch --config-file=/home/myuser/swatch/td-swatch-config --tail-file=/my/app/path/logs/tomcat/stdout-stderr-********.log --daemon

to cron and have it always know to tail today’s log, whether it be stdout-stderr-20180801.log or stdout-stderr-20190101.log, etc.

Can you help me with that? Is there an easy way? One thing I thought of would be to put the swatch command in its own script which uses variables to define the right filename (ex. dateString={date +”%m-%d”//[-]/} tailString= ‘/opt/blackboard/logs/tomcat/stdout-stderr’+$dateString+’.log’) and then run that swatchdog script every day. But then is there more overhead on effectively killing the swatchdog process when it no longer needs to be watching a file that won’t change anymore?

Advise pretty please : )

]]>
By: Ravi Saive https://www.tecmint.com/swatch-linux-log-file-watcher/comment-page-1/#comment-1020076 Wed, 01 Aug 2018 08:44:33 +0000 https://www.tecmint.com/?p=30180#comment-1020076 In reply to neo.

@Neo,

That’s not enough, because Swatchdog uses regular expression and pattern to monitor particular string in a log file, also it has a feature to highlight those string in bold or color fashion in the output.

]]>