How to tail -f multi logfile in 1 shell script.?


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Hammer & Screwdriver How to tail -f multi logfile in 1 shell script.?

Hello,

How to tail -f multi logfile from multi path in 1 shell script.

File & Path
Code:
/usr/home/localmode/mode110l/log/logic/number110/digit110_digit110m4_2013050210.txt
/usr/home/localmode/mode103l/log/logic/number103/digit103_digit103m4_2013050210.txt
/usr/home/localmode/modegwl/log/logic/number140/digit140_digitgwm10_2013050210.txt
/usr/home/localmode/modegwl/log/logic/number102/digit102_digitgwm10_2013050210.txt

I need output as below
tail -f log file in 1 shell script and 1 wondow
O/P:

Code:
tail-f /usr/home/localmode/mode110l/log/logic/number110/digit110_digit110m4_2013050210.txt
2013-05-02 10:56:09,465|1|
2013-05-02 10:56:09,689|1|
2013-05-02 10:56:09,902|1|
2013-05-02 10:56:09,915|1|

------------------------------------------------------------------------------------------
tail-f /usr/home/localmode/mode103l/log/logic/number103/digit103_digit103m4_2013050210.txt
2013-05-02 10:56:10,067|1|
2013-05-02 10:56:10,129|1|
2013-05-02 10:56:10,131|1|

------------------------------------------------------------------------------------------
tail-f /usr/home/localmode/modegwl/log/logic/number140/digit140_digitgwm10_2013050210.txt
2013-05-02 10:56:10,895|1|
2013-05-02 10:56:11,283|1|
2013-05-02 10:56:11,881|1|
2013-05-02 10:56:14,072|3|
2013-05-02 10:56:15,323|1|
2013-05-02 10:56:15,528|1|
2013-05-02 10:56:15,578|1|

------------------------------------------------------------------------------------------
tail-f /usr/home/localmode/modegwl/log/logic/number102/digit102_digitgwm10_2013050210.txt
2013-05-02 10:56:15,604|1|
2013-05-02 10:56:15,628|1|
2013-05-02 10:56:15,768|1|

------------------------------------------------------------------------------------------

# 2  
try this one!
tail -f /usr/home/localmode/mode110l/log/logic/number110/digit110_digit110m4_2013050210.txt /usr/home/localmode/mode103l/log/logic/number103/digit103_digit103m4_2013050210.txt ... file names

Last edited by Revansidhu; 05-02-2013 at 01:11 AM..
# 3  
Quote:
I need output as below
You can't do it exactly like that. The best you can do is:
Code:
tail -f \
/usr/home/localmode/mode110l/log/logic/number110/digit110_digit110m4_2013050210.txt \
/usr/home/localmode/mode103l/log/logic/number103/digit103_digit103m4_2013050210.txt \
/usr/home/localmode/modegwl/log/logic/number140/digit140_digitgwm10_2013050210.txt \
/usr/home/localmode/modegwl/log/logic/number102/digit102_digitgwm10_2013050210.txt

In other words tail -f a b c d
# 4  
Quote:
Originally Posted by Revansidhu
try this one!
tail -f /usr/home/localmode/mode110l/log/logic/number110/digit110_digit110m4_2013050210.txt /usr/home/localmode/mode103l/log/logic/number103/digit103_digit103m4_2013050210.txt ... file names
in not work.

---------- Post updated at 11:33 AM ---------- Previous update was at 11:32 AM ----------

Quote:
Originally Posted by hanson44
You can't do it exactly like that. The best you can do is:
Code:
tail -f \
/usr/home/localmode/mode110l/log/logic/number110/digit110_digit110m4_2013050210.txt \
/usr/home/localmode/mode103l/log/logic/number103/digit103_digit103m4_2013050210.txt \
/usr/home/localmode/modegwl/log/logic/number140/digit140_digitgwm10_2013050210.txt \
/usr/home/localmode/modegwl/log/logic/number102/digit102_digitgwm10_2013050210.txt

In other words tail -f a b c d
in not work
Code:
usage: tail [+/-[n][lbc][f]] [file]
       tail [+/-[n][l][r|f]] [file]

# 5  
Works here. Maybe your version of tail only allows one file name.
Code:
$ ls file*
file1  file2

Code:
$ tail -f file1 file2
==> file1 <==
Wed May  1 21:00:28 PDT 2013
Wed May  1 21:03:26 PDT 2013

==> file2 <==
Wed May  1 21:00:34 PDT 2013
Wed May  1 21:03:24 PDT 2013

Code:
$ tail --version
tail (GNU coreutils) 8.13

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Merge multi-lines into one single line using shell script or Linux command

Hi, Can anyone help me for merge the following multi-line log which beginning with a " and line ending with ": into one line. *****Original Log***** 087;2008-12-06;084403;"mc;;SYHLR6AP1D\LNZW;AD-703;1;12475;SYHLR6AP1B;1.1.1.1;0000000062;HGPDI:MSISDN=12345678,APNID=1,EQOSID=365;... (3 Replies)
Discussion started by: rajeshlinux2010
3 Replies

2. Shell Programming and Scripting

Shell script, sftp logfile not showing transfer information

Hello, Recently I have changed some crontab scripts which I execute to do different tasks mainly transfering some files from one server to the other. The main change was the protocol from ftp transfer to sftp. Ftp server was the MS Windows default service, and Sftp server is an proprietary sw... (4 Replies)
Discussion started by: enux
4 Replies

3. Shell Programming and Scripting

Logfile monitoring with logfile replacement

Bonjour, I've wrote a script to monitor a logfile in realtime. It is working almost perfeclty except for two things. The script use the following technique : tail -fn0 $logfile | \ while read line ; do ... some stuff done First one, I'd like a way to end the monitoring script if a... (3 Replies)
Discussion started by: Warluck
3 Replies

4. UNIX for Dummies Questions & Answers

Shell script to email logfile

Hi, I am trying to write a shell script to send a log file of a query run in oracle.Pls help me I am very new to shell scripting. echo " Checking Activity Spec " sqlplus / as sysdba <<END_SQL @activity_spec_metadata.sql quit;>>logfile END_SQL mailx -s "Checking Activity Spec schedule... (1 Reply)
Discussion started by: Rossdba
1 Replies

5. Shell Programming and Scripting

How to tail -f logfile. if log file is generate every 1 HR.?

Hello, How to tail -f logfile. if log file is gennerate every 1 HR. I want it works automatically all the time. never changes it by manual. Thank ls -trl CybertonTransaction.* -rw-r--r-- 1 autobot robot 617071 Jul 9 00:02 CybertonTransaction.20130709-00.log -rw-r--r-- 1 autobot ... (12 Replies)
Discussion started by: ooilinlove
12 Replies

6. Shell Programming and Scripting

generate logfile in a shell script

Unix Gurus, I have a shell script which has few "echo" statements. I am trying to create a logfile where all the outputs of the echo statement sare stored. I will have to add this as the final step in the existing script so that everytime the script runs, a logfile is generated with all the... (1 Reply)
Discussion started by: shankar1dada
1 Replies

7. Shell Programming and Scripting

Reading multi lines variable using shell script

Hi, I am using #!/bin/sh shell. I have a variable which contains multi line data. I want to read that variable line by line. Can someone post the code to read the multi line variable line by line? Any help is much appreciated. (2 Replies)
Discussion started by: gupt_ash
2 Replies

8. Shell Programming and Scripting

Logfile monitor script

Hi, I'm trying to write a logfile monitor script that reads the logfile and then emails out once there is an error with SQL in. Here is my attempt below which does not work. I'm not much of a scripter as you can probably see but some pointers in the right direction would be much appreciated. ... (3 Replies)
Discussion started by: elmesy
3 Replies

9. Shell Programming and Scripting

Grep or Tail in shell script

Hi, I am writing a shell script that checks catalina logs on a production system and mails me if it detects errors. It greps the logs for known errors which i have defined as variables. The problem is the logs are huge, approx 30,000 before they rotate. So I am forced to use grep instead... (3 Replies)
Discussion started by: Moxy
3 Replies

10. Shell Programming and Scripting

Korn Shell Script to find out error in logfile

Hi All, I am new to this forum as well as to unix scripting. Can you please help me to create a korn shell script to find out errors in logfiles and get the name of that logfile ( which is having error) in email and email it to me? (2 Replies)
Discussion started by: jithu
2 Replies

Featured Tech Videos