Continuous log file transfer to remote server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Continuous log file transfer to remote server
# 1  
Old 06-08-2011
Continuous log file transfer to remote server

I have several production servers and 1 offline server. Production server continuously generates new log files for my application. Depending on time of day new files may be generated every few seconds and at other times every few hours. I also have an offline server where I would like to pull log files from all my production server and crunch information from all those logs. I want to to do this in near real time meaning as soon as production server finishes writing to a file and starts writing to a new file I want to transfer the previous file that has just been completed. When the new file completes I want to copy that and so on 24x7. I think a daemon process on offline server that checks for most recent file that has been closed and then transfers it would do the trick but I don't know how to implement my idea. Can someone share ideas on how to do this?
thanks
# 2  
Old 06-08-2011
Do you manage the script that generate the logs or are they generated by some "blackbox-application-binaries" ?
Are they located in a specific PATH (which) ?
do they have a naming convention (which) ?
# 3  
Old 06-08-2011
Checking when a file is closed means busting out strange applications like fuser or lsof. Why not just watch for when a newer one is created? Some silly pseudocode:
Code:
last_updated=$(ls --sort=time /path/to/log | head -n 1)

while true
do
        ls --sort=time /path/to/log > /tmp/$$
        read latest < /tmp/$$
        if [ ! "$latest" = "$last_updated" ]
        then
                new="$latest"
                exec 5</tmp/$$
                # Skip the file being written to
                read latest <&5
                read latest <&5
                while [ ! "$latest" = "$last_updated" ]
                do
                        cp "$latest" /wherever
                        read latest <&5
                done
                exec 5<&-

                cp "$last_updated" /wherever
                last_updated="$new"
        else
                sleep 1
        fi        
done

You could potentially make it much smarter, not needing to run ls repeatedly and all that, by knowing more about the pattern this thing creates logfiles in.

You could also use NFS or somesuch to have the server create the files on the other machine in the first place, instead of having to continuously watch and copy.
# 4  
Old 06-09-2011
Quote:
Originally Posted by ctsgnb
Do you manage the script that generate the logs or are they generated by some "blackbox-application-binaries" ?
Are they located in a specific PATH (which) ?
do they have a naming convention (which) ?
Logs are generated by an application. I think application uses logpipe mechanism. Yes they are all located in a specific path and path is specific to application.
They all follow a naming convention of abc165.22.34 where 165 is julian day (date +%j), and uses hour and minute time stamp so 22 is hour and 34 is minute and the value is picked when the new log file is opened.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File transfer from remote to local

Hi, I came across the scenario, that I need to copy files from the remote server to my local. The files in the remote server are created by another job and its keep on generating the files in that remote folder. We can't able to use SCP command and we're using SFTP to connect the server and... (3 Replies)
Discussion started by: Janarthan
3 Replies

2. UNIX for Advanced & Expert Users

Best way to transfer files to remote FTPS server instead of local FTPS server

Hi, I am working on an application which runs on an Informatica Red-Hat 5.10 Linux Server. The application involves several Informatica ETL workflows which generate 100s of Text files with lot of data. Many of the files will each be up to 5 GB in size. Currently the Informatica server itself... (7 Replies)
Discussion started by: waavman
7 Replies

3. Shell Programming and Scripting

Do I require remote login access to a windows server to transfer files from a UNIX server

Hi All I need to transfer a file from a UNIX server to a windows server. I saw that it is possible to do this using scp command by looking at the forum listed below: ... (2 Replies)
Discussion started by: vx04
2 Replies

4. UNIX for Dummies Questions & Answers

Remote file transfer between Linux and Windows

Hello, I have a file, say details.txt on my windows machine. I want to copy it to linux machine through a shell script and edit the file and transfer the file back to windows machine. (All I want to do is to edit the file on windows machine from linux machine by a script.) I have tried scp... (1 Reply)
Discussion started by: Devendra Hupri
1 Replies

5. UNIX for Dummies Questions & Answers

Syslog Messages from Remote Server are not writing to Log File Anymore

Hello All, Server: SUSE Linux Enterprise Server 11.3 (x86_64) Syslog-ng Version: syslog-ng 2.0.9 We have configured a Cisco router to send it's log messages to this server listed above. This has been working just perfectly for the last couple months, but we had never setup the log... (9 Replies)
Discussion started by: mrm5102
9 Replies

6. UNIX for Dummies Questions & Answers

Transfer file from server B to server C and running the script on server A

I have 3 servers A, B, C and server B is having some files in /u01/soa/ directory, these files i want to copy to server C, and i want to run the script from server A. Script(Server A) --> Files at Server B (Source server) --> Copy the files to Server C(Target Server). We dont have RSA key... (4 Replies)
Discussion started by: kiran_j
4 Replies

7. Shell Programming and Scripting

Using SFTP and FTP to transfer data from One Remote Server To Another

HI I need to write a script in 415univ server which should go to 534unix server and move the files from there to windows server. I am not able to get it bcoz sftp prompt is not allowing ftp command. Can some one plz help me Thanks in advance (3 Replies)
Discussion started by: himakiran9
3 Replies

8. Shell Programming and Scripting

Transfer file from local unix server to remote server

want to remove this thread. thanks (2 Replies)
Discussion started by: indira
2 Replies

9. HP-UX

Transfer file from local unix server to remote server

want to remove the thread thanks (2 Replies)
Discussion started by: indira
2 Replies

10. UNIX for Dummies Questions & Answers

SCO Openserver 6 Remote File Transfer

Hi, I have a server which has SCO Openserver 6 on it and also kermit installed, unfortunately I can't seem to get kermit to send or receive files, is there another way I can use to transfer files remotely? I only have remote access to the server via a dial up modem Any comments/suggestions... (1 Reply)
Discussion started by: Martyn
1 Replies
Login or Register to Ask a Question