Home » Scripts » Shell Script to Tail Today’s Syslog-NG logs

Shell Script to Tail Today’s Syslog-NG logs

Shell Script to Tail Today's Syslog-NG logsHere is a simple shell script (one-liner) to automatically start tailing today’s syslog-ng logs for a single device.

Shell Script to Tail Today’s Syslog-NG logs

Laziness is powerful, so if you are tired of typing the full path to today’s syslog-ng log files, for your device, here is a simple method to use it. You will need to change the 192.168.1.1 IP Address to the address of your device (or hostname, if applicable).

logtail.sh
#!/bin/sh
tail -f /Logs/firewalls/192.168.1.1/`/bin/date +\%Y`/`/bin/date +\%m`/192.168.1.1-`/bin/date +\%Y-%m-%d`.log

If you like a little color, when displaying your logs, here is the same example using colortail instead of tail.

colortail.sh
#!/bin/sh
colortail -f /Logs/firewalls/192.168.1.1/`/bin/date +\%Y`/`/bin/date +\%m`/192.168.1.1-`/bin/date +\%Y-%m-%d`.log

Enjoy logging in and running ./logtail.sh instead of typing in the full command line every time!

 


unixsamurai.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. Read our Privacy Policy for more info.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.