syslog: automatic date script

From CCIE networking & linux
Jump to: navigation, search

Receiving live Syslog messages from another location. Normaly I would display live local syslog messages with this command:

tail -f /var/log/syslog

Suppose that there is a syslog server somewhere in the network at the ip addres 1.2.3.4. I have sucesfully mounted this Windows syslog server under my link

/mnt/asf-syslog/

but the three structure creates every day a new directory with current date with current syslog file.

laptop:/mnt/asf-syslog$ ll
drwxr-xr-x  1 root root         0 2013-06-21 00:00 ./
drwxr-xr-x 12 root root      4096 2013-05-29 13:52 ../
drwxr-xr-x  0 root root         0 2012-10-01 00:00 2012-10-01/
drwxr-xr-x  0 root root         0 2012-10-02 00:00 2012-10-02/
drwxr-xr-x  0 root root         0 2012-10-03 00:00 2012-06-21/

the actual syslog file name is actual-syslog.txt So the full path would be:

/mnt/asf-syslog/2013-06-21/actual-sylog.txt

How to overcome the changing syslog directory every day?

#!/bin/bash
# ccienux: 20-06-13 script which will turn on syslog from actual date and time
echo ">>> Starting SYSLOG for today" $(date +"%Y-%m-%d")
echo "........................................................................"
tail -f /mnt/asf-syslog/$(date +"%Y-%m-%d")/actual-syslog.txt

what command "date" does is, he prits out current date or time in desired format. For more details see man date I just call this program it "syslog" and when I enter the command into CMD it will start automatically.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox
Offer
Martin Satara