Tail -f Command help


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Tail -f Command help
# 8  
Old 11-30-2018
Hi Don Cragun,

I cannot share the file data over here due to company policies, and even there is no code written for this...
I just login into server through Putty and use tail -f server.log
to see the contents of the logs. And this file keeps only appending with new logs (ERROR, WARN and INFO lines), it does not edit the previous lines which have already written in past.

I just wanted to have this file to be copied/synced in my local windows drive so that I can view the logs realtime (but in Windows drive).

when you tail should be all you need to keep with with changes being added to the file on the remote server and should also be able to keep a local copy of the file up-to-date with text appended to that file on the remote system, can you elaborate how this can be achieved.

Thanks in advance and Sorry if I missed anything.
# 9  
Old 11-30-2018
Basically, in modern environments one should have some kind of log shipping service/agents, and process those logs on central server.
There are free, open, proprietary etc. systems, which do the same thing, ship logs you want to central server.

As i see it you have couple of choices on Windows :

1. NFS, export the log directory via NFS from server and mount it on Windows box (windows 7 or later) - this is closest to 'real time' you will get.
2. rsync copy - not so 'real time' as NFS, but close, depending on the network bandwidth / cpu and scheduled times (every minute or 2 etc.)
3. Remote syslog on windows PC -> this will require your application to use syslog for logging with one of the local facilities and syslog configured to send logs to Windows PC.
Depending on again bandwidth, quantity of logging etc. can be a performance hit on the client you wish to pull logs off.

This is all, from my point of view, not production ready and could be / is considered hackery.
A regular solution would be to use software written for that purpose.

What do you consider as real time?
I consider that to be almost instant, in regards time needed to read from disk, send it over the wire, and write to disk in windows.
Those ops are measured in milliseconds.

Hopefully we can neglect the CPU time required for that operation, but it is software implementation dependent.
For instance, if you use rsync with compression and checksum, it is bound to take more cpu (and other) resources then an agent made especially for that purpose.
Also, running scheduled rsyncs on large log files will cause that entire file to be cached in memory, changing the memory footprint of the box.
Above can be irrelevant if there is enough memory, but can also cause log files to be cached instead of other things, making those other things visible to users as slowdowns Smilie

Hope that helps
Regards
Peasant.
# 10  
Old 11-30-2018
Quote:
Originally Posted by jitensetia
I would me more happy if I can pull the server.log file to my local Windows directory and it should be updating continously as it do on the server.
Files do not work that way.
# 11  
Old 11-30-2018
Quote:
Originally Posted by jitensetia
Hi Don Cragun,

I cannot share the file data over here due to company policies, and even there is no code written for this...
I just login into server through Putty and use tail -f server.log
to see the contents of the logs. And this file keeps only appending with new logs (ERROR, WARN and INFO lines), it does not edit the previous lines which have already written in past.

I just wanted to have this file to be copied/synced in my local windows drive so that I can view the logs realtime (but in Windows drive).

when you tail should be all you need to keep with with changes being added to the file on the remote server and should also be able to keep a local copy of the file up-to-date with text appended to that file on the remote system, can you elaborate how this can be achieved.

Thanks in advance and Sorry if I missed anything.
I didn't ask you to share any file data (other than the sample data you have already shown us and a clearer explanation of the format of the data you are trying to process).

I asked you to explain how you are currently accessing the remote file using applications running on Windows. From your response, I assume that you have no way to access the file. Using NFS to mount the remote file onto your windows server (acting as a cliient in this case) would allow a tail -f command on Windows to access your remote file seeing additions to that file in real-time. Anything else will introduce delays and complications.

As Corona688 said, unless you have established remote access to a file, it won't magically create a copy of itself on another server.
# 12  
Old 12-01-2018
Quote:
Originally Posted by Don Cragun
As Corona688 said, unless you have established remote access to a file, it won't magically create a copy of itself on another server.
Wouldn't a continuously (or, rather, often enough to meet the "real-time" requirements) updated rsync-ed copy of the file suffice? Depending on the size one could also set up a cron job to do something similar with the complete file via [icode]ssh[i/code]/[icode]scp[i/code].

But all this means there at least some means to do what has to be done. But i am not allowed to touch the file, read it, transfer it or even access it but somehow i should process it is a matter of (stupid) regulations. You can't alleviate regulations via code, just by changing the regulations: "you want me to process the file, then give me access to it" is the correct way of doing things in such a case.

I hope this helps.

bakunin
These 2 Users Gave Thanks to bakunin For This Post:
# 13  
Old 12-04-2018
Thanks @Bakunin for the insight.

I have the read only access over the file as said... I can view the file over Putty by tail -f command.
Can you help me how I can set the sync with NFS... a URL where I can learn how to setup NFS services to sync the file from server with local Windows machine.

Thanks a lot
# 14  
Old 12-04-2018
To repeat: Files do not work that way. Even when you share the file -- which you can't without big changes in your server -- you'll be stuck running tail -f in a local terminal instead of a remote one, because text editors don't work that way either.
Quote:
But --
Files do not work that way.
Quote:
-- maybe if I --
Files do not work that way.
Quote:
-- But why can't I --
Because files don't work that way.

It would be worth your while to reconsider the problem from any other angle besides "magically growing file", or better yet, explain what you actually want. You might be quite surprised when you go through all the trouble of setting up an NFS only to discover that what you thought you needed hasn't actually solved your problems. tail -f in putty actually works surprisingly well.

Perhaps, is the problem the inconvenience of having to type passwords into putty? There are automatic login features you could be using. putty can do logging, also, and even network forwarding, allowing you to connect to services on the server.

Otherwise, you have information you wish to transmit from point A to point B in realtime. Perhaps netcat?

You could do full-out network or centralized logging, perhaps, and have an infrastructure to warn you of certain events.

Last edited by Corona688; 12-04-2018 at 02:40 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. How to Post in the The UNIX and Linux Forums

Usage of tail command in .awk

Hi, I want to do file format using awk script, for that i wan to use 'tail'. Here is the scenario. I will be having set of files in a directory. Those files i need to write to another directory with same file name, but while writing the file to out directory, i need to write the last line as... (3 Replies)
Discussion started by: Venkata Madhu
3 Replies

2. Homework & Coursework Questions

Using tail with the filter command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Devise a chain of filters using some or all of the following programs pr, cut, cat, tail to display a numbered... (8 Replies)
Discussion started by: hbell221
8 Replies

3. Shell Programming and Scripting

tail command help

Hi does anyone know how to create a file using the tail command? My book has this file I need to create and it says to use the tail command and that it is possible but I have no idea. Thanks. (4 Replies)
Discussion started by: drew211
4 Replies

4. Shell Programming and Scripting

tail command problems

Hi, In my home directory, there are so many files. i tried to get the lastly created file by following command. file=`ls -lrt MXOfiles* | tail -1` As there are so many files, it displays "$ : 0403-027 The parameter list is too long." Can someone tell me how can i get the recent file... (1 Reply)
Discussion started by: JSKOBS
1 Replies

5. UNIX for Dummies Questions & Answers

Tail command with wildcard file name

Please help with the following command tail -f /appdata/logs/alert_audit517.txt | grep "Sep 02" The problem I have is with the file name "alert_audit517.txt". The 3 digit number at the end of the file name changes, so I need the file name to use a wildcard. Ive tried alert_audit***.txt, but... (5 Replies)
Discussion started by: robertson1995
5 Replies

6. Shell Programming and Scripting

Help with tail command

Hi All, My query seems to be silly but Iam unable to find where the exact problem lies. I have a script to unzip set of files here is the script #!/bin/ksh Count=`cat /home/gaddamja/Tempfile | wc -l` while do Filename=`cat /home/gaddamja/Tempfile |tail -$Count | head -1` cd... (7 Replies)
Discussion started by: jagadish_gaddam
7 Replies

7. Solaris

Tail command in one line

HI i have to copy the last 5000 lines form a log file and copy the same in the same file .overwriting the same log file. ex: tail -5000 testfile1 > testfile2 cat testfile2 mv tesftfile2 testfile1 will produce the correct result.but i want to have this done in one line???? (4 Replies)
Discussion started by: saurabh84g
4 Replies

8. Shell Programming and Scripting

tail command..

I was wondering how can I do this I have file myfile.txt wc -l is: 5 000 000 I have to remove first 1 000 000 lines from header.. I tryed with tail -4000000 myfile.txt>newfile.txt but it does not work... any help?? (2 Replies)
Discussion started by: amon
2 Replies

9. Shell Programming and Scripting

tail command

Hi , I have found a interesting thing about tail command: when I tried to use 'tail -1 *' to look at every file with the current derectory, I only got one line of result of one file. But if I use 'head -1 *', I would get multiple lines. Is there a way to do get multiple lines with 'tail -1 *'... (3 Replies)
Discussion started by: whatisthis
3 Replies

10. UNIX for Advanced & Expert Users

help with !(tail -2) command.. using pipes

I am trying to using pipe (|) with ! (not) operator to list all the other files except the latest two and I am using the following command. $ ls -ltr *.lst|!(tail -2) ksh: 20050211180252.lst: cannot execute but it is trying to execute the file returned by tail -2. I am able to do that in 4... (8 Replies)
Discussion started by: sdlayeeq
8 Replies
Login or Register to Ask a Question