Sponsored Content
Top Forums Shell Programming and Scripting Continuous log file transfer to remote server Post 302529194 by Corona688 on Wednesday 8th of June 2011 06:27:54 PM
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.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
nfs(5nfs)																 nfs(5nfs)

Name
       nfs - Network File System

Description
       The Network File System (NFS) is a specific file system implemented under the Generic File System Interface, as described in

       NFS  provides  support  for sharing ordinary files and directories in a multivendor networking environment.  The system administrator for a
       file server machine makes a file system available for remote access by placing the name of the file system to be shared in an export  list.
       The  administrator for a client machine can import a file system from any server machine that has granted access permission to the request-
       ing client machine.  A complete exported file system or any subtree of an exported file system can be imported by the client machine.  Once
       imported, users on the client machine can access files in the remote file system as though they were local files.

See Also
       getdirentries(2), getmnt(2), mount(2nfs), mount(2), exports(5nfs), fstab(5), gfsi(5), mount(8nfs), showmount(8nfs)

																	 nfs(5nfs)
All times are GMT -4. The time now is 09:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy